Link to home
Start Free TrialLog in
Avatar of jazzIIIlove
jazzIIIloveFlag for Sweden

asked on

C# capturing 2 keys, shift and F5 keys during debugging in VS 2010, any way/workaround?

Hi there;

I need to capture 2 keys, shift and F5 keys during debugging for C# in VS 2010, any way/workaround?

When I press shift, the debugger is unable to get F5, and I cannot trace my code.

Kind regards.
Avatar of dj_alik
dj_alik

Set focus to your app and to code and try press
Set focus to your app and not to editor and try press
Avatar of bromy2004
Set a debugging point in the IF condition where the SHIFT & F5 are true
i.e.
if (key1==true & key2==true)

//BreakPoint here

endif

Open in new window

Avatar of jazzIIIlove

ASKER

?
>>?
to dj_alik.

bromy2004:
Thanks for the interest. When I did so, e.g. during debugging it gets only shift and only key1 accepted as true, whereas key2 is not.

my code is as:

if(e.Shift && e.KeyCode == Keys.F8)
{
...

Kind regards.
No matter how quick you are, key events are received one at a time,
if you pressed 10 keys at once they would be processed in a queue.

When a keydown or keypress is handled you can look at
some boolean properties of the event:
ctrlKey,shiftKey,altKey each return true if the corresponding key was depressed
when the key event was handled.

Or you can build an array of key's on every keydown and wait to process them all when the next keyup event occurs.
I think you can do this by setting a static boolean value to true for shift press.
if that boolean value is true, and e.KeyCode == Keys.F8 is also true,
that means, you achieved shift +F8

my code:
if(e.Shift && e.KeyCode == Keys.F8)

doesn't it serve for the same boolean purpose?

Kind regards.
What I meant was if you put a breakpoint in the if statement. Not on the actual "if" but the line after
Like on:
Console.WriteLine("Shift + F5 was pressed")

Even if there are 20 keys pressed it will only break when the if condition is true.
ASKER CERTIFIED SOLUTION
Avatar of Niyas
Niyas

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ah, yes. got the point.