How can I get keyboard keys?
ex. a-z; 0-9; etc.
Is there a keyboard ontrol or something? |
| micd7 Sunday, December 30, 2007 9:52 PM |
You're not going to automatically capture anything but the keys that are meant to be used together ... and that is the ctrl+anykey and shift+anykey ... and then only in the KeyPress event (the KeyDown and KeyUp will capture them singly).
pressing:shift + a
KeyPress: A
KeyDown: Shift, A
So, my suggestion is that you use the KeyPress event to capture the keys, but concatenate them and store them in a variable. Maybe also have a variable that stores the time of the keypress so that you know when to reset your string variable. |
| BonnieB Tuesday, January 01, 2008 4:39 PM |
Look at the KeyPress, KeyUp and/or KeyDown event handlers. |
| BonnieB Monday, December 31, 2007 1:02 AM |
how can I get multiple keys at once?
ex. a & b; 1 & 2;etc. |
| micd7 Monday, December 31, 2007 7:02 AM |
Can you explain your exact requirement? |
| Prasant Swain Monday, December 31, 2007 7:33 AM |
Any and every key on the keyboard that's pressed.
ex. a-z; 0-9; special chars; arrows; F1-12; tab; caps; shift left; shift right; ctrl; alt; windows key; context menu key; the hotkeys; etc.
Basically put, a string of every possible key on the keyboard that can be pressed. As well I need to be able to capture all pressed keys not just the first. |
| micd7 Monday, December 31, 2007 9:38 AM |
Okey then you set the KeyPreview property of the form to True..
and then in the KeyDown event of the Form you can catch all the key pressed..
|
| Prasant Swain Monday, December 31, 2007 10:24 AM |
Hmm that works to get all the keys, yes but only one at a time. How can I get every key currently pressed?
Also how can I make the form view the keys even without window focus?(ex. IE explore has the focus and my program does not.) |
| micd7 Tuesday, January 01, 2008 3:37 AM |
I'm guessing that you might be talking about CTRL + {another key} type of scenario? For that, use the KeyPress event instead of the KeyDown event.
As for your other question, I'm afraid I can't help you with that ... I'm not sure that it can be done, but I could be wrong. |
| BonnieB Tuesday, January 01, 2008 5:29 AM |
Well ctrl+{key} Is one example but I mean stuff like these examples:
Examples
pressing: esc+{a &b}
returns: escape, a, and b
pressing: Wake up+F1+Tab
returns: Wake up, {F1}, and Tab
pressing: a+g+t
returns: a,g, and t
presing: shift+a+g
returns: {Shift}, A, and G
Get my drift? |
| micd7 Tuesday, January 01, 2008 11:43 AM |
You're not going to automatically capture anything but the keys that are meant to be used together ... and that is the ctrl+anykey and shift+anykey ... and then only in the KeyPress event (the KeyDown and KeyUp will capture them singly).
pressing:shift + a
KeyPress: A
KeyDown: Shift, A
So, my suggestion is that you use the KeyPress event to capture the keys, but concatenate them and store them in a variable. Maybe also have a variable that stores the time of the keypress so that you know when to reset your string variable. |
| BonnieB Tuesday, January 01, 2008 4:39 PM |
Hmm well ok, thisthread didn't help me as much as I hoped but I'll try your last suggestion and try making a user control out of it somehow. Thx |
| micd7 Tuesday, January 01, 2008 9:11 PM |
That's the bestone can do, based on how the events work. My suggestion should get you pointed to a workable solution though. Let us know if you run into any snags and have any other questions.  |
| BonnieB Tuesday, January 01, 2008 10:18 PM |