Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2011-05-12
12
Medium Priority
?
969 Views
Last Modified: 2012-06-22
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
Comment
Question by:jazzIIIlove
  • 4
  • 4
  • 2
  • +1
12 Comments
 
LVL 18

Expert Comment

by:dj_alik
ID: 35744878
Set focus to your app and to code and try press
0
 
LVL 18

Expert Comment

by:dj_alik
ID: 35744879
Set focus to your app and not to editor and try press
0
 
LVL 10

Expert Comment

by:bromy2004
ID: 35744948
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35745019
?
0
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35745035
>>?
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
 
LVL 1

Expert Comment

by:Niyas
ID: 35746582
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
 
LVL 1

Expert Comment

by:Niyas
ID: 35746598
0
 
LVL 1

Expert Comment

by:Niyas
ID: 35746859
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35750875
my code:
if(e.Shift && e.KeyCode == Keys.F8)

doesn't it serve for the same boolean purpose?

Kind regards.
0
 
LVL 10

Expert Comment

by:bromy2004
ID: 35751900
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
 
LVL 1

Accepted Solution

by:
Niyas earned 2000 total points
ID: 35752201
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
 
LVL 12

Author Comment

by:jazzIIIlove
ID: 35752546
ah, yes. got the point.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question