• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 988
  • Last Modified:

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.
0
jazzIIIlove
Asked:
jazzIIIlove
  • 4
  • 4
  • 2
  • +1
1 Solution
 
dj_alikCommented:
Set focus to your app and to code and try press
0
 
dj_alikCommented:
Set focus to your app and not to editor and try press
0
 
bromy2004Commented:
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

0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
jazzIIIloveAuthor Commented:
?
0
 
jazzIIIloveAuthor Commented:
>>?
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.
0
 
NiyasCommented:
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.
0
 
NiyasCommented:
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

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

doesn't it serve for the same boolean purpose?

Kind regards.
0
 
bromy2004Commented:
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.
0
 
NiyasCommented:
Your condition

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

will not be true.
Since key events are received one at a time,
if you pressed 10 keys at once they would be processed in a queue.

if(e.Shift)
{
//set boolean to true
}


if(boolean==true)
{
if(e.KeyCode == Keys.F8)
{
//your code here
}


}
0
 
jazzIIIloveAuthor Commented:
ah, yes. got the point.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 4
  • 4
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now