jazzIIIlove
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.
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.
Set focus to your app and to code and try press
Set focus to your app and not to editor and try press
Set a debugging point in the IF condition where the SHIFT & F5 are true
i.e.
i.e.
if (key1==true & key2==true)
//BreakPoint here
endif
ASKER
?
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.
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.
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
if that boolean value is true, and e.KeyCode == Keys.F8 is also true,
that means, you achieved shift +F8
ASKER
my code:
if(e.Shift && e.KeyCode == Keys.F8)
doesn't it serve for the same boolean purpose?
Kind regards.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ah, yes. got the point.