R
Richard Kucia
I'm trying to intercept the arrow and return keystrokes with the KeyDown
event. Yes, I've tried the McSoft package and it won't work for me.
I believe a TextBox and only one or two other controls make the KeyDown
event available. For my testing, added a handler to a textbox's KeyDown
event. Upon each event, I added the KeyCode to a combo box. I found some
interesting results which I am happy to share here. In all tests, I set the
focus to the textbox and pressed the Up, Down, Left, Right and Return keys
in order. The test results show the KeyCode.ToString results generated from
each physical key pressed. Note that in some cases, one human action
produced two events (i.e. two keypresses were generated).
Test 1: Emulator; clicking the star pad with the mouse
Up, F21
Down, F21
Left, F21
Right, F21
Return
Test 2: Emulator, clicking the arrow keys on the SIP
Up
Down
Left
Right
Return
Test 3: Emulator, pressing keys on the host computer
Up, F20
Down, F20
Left, F20
Right, F20
Return
Test 4: Compaq iPaq, tapping keys on the SIP
Up
Down
Left
Right
Return and a beep
Test 5: Compaq iPaq, pressing the star pad
Up, F21
Down, F21
Left, F21
Right, F21
F23, Return and a beep
And that leads to a few questions:
1) What's with the the F20, F21 and F23 keycodes? What do they signify? It
would make some sense if the F## keystroke always preceded the usual keycode
(so the software could perhaps handle the star pad differently from the
SIP), but it's a real kludge if the F## keystroke follows the usual keycode.
2) Can I get rid of the beep? I tried setting AcceptsReturn both ways on the
textbox and that didn't seem to affect the beep.
3) What other controls support KeyDown detection?
4) Design question: I've got a tab control with 4 tab pages. The tab page of
interest to me has a bunch of buttons, combo boxes, trackbars, etc. There's
also a bunch of combo boxes and list views that are outside the entire tab
control. I don't need the SIP for any of these controls. I'd like to use the
Up/Down/Return keys from the star pad. What do you think about this
approach:
* deriving a class ("MyGizmo") from one of the controls that supports
KeyDown (probably not the TextBox since it beeps for Return)
* instantiating Gizmo on the tab page of interest
* setting the Gizmo invisible (or, if it must be visible in order to get
focus, then creating a 1-pixel screen representation)
* adding a handler to all the other screen controls' GotFocus event to send
the focus over to the Gizmo control
* adding a handler to the Gizmo KeyDown event; if the tab control's selected
tab page is the one I'm interested in, and the keycode is one of my special
keycodes, then do whatever needs to be done and mark the keycode as handled
Boy, I sure wish I had a form-level KeyPreview....
Thanks.
Richard Kucia
event. Yes, I've tried the McSoft package and it won't work for me.
I believe a TextBox and only one or two other controls make the KeyDown
event available. For my testing, added a handler to a textbox's KeyDown
event. Upon each event, I added the KeyCode to a combo box. I found some
interesting results which I am happy to share here. In all tests, I set the
focus to the textbox and pressed the Up, Down, Left, Right and Return keys
in order. The test results show the KeyCode.ToString results generated from
each physical key pressed. Note that in some cases, one human action
produced two events (i.e. two keypresses were generated).
Test 1: Emulator; clicking the star pad with the mouse
Up, F21
Down, F21
Left, F21
Right, F21
Return
Test 2: Emulator, clicking the arrow keys on the SIP
Up
Down
Left
Right
Return
Test 3: Emulator, pressing keys on the host computer
Up, F20
Down, F20
Left, F20
Right, F20
Return
Test 4: Compaq iPaq, tapping keys on the SIP
Up
Down
Left
Right
Return and a beep
Test 5: Compaq iPaq, pressing the star pad
Up, F21
Down, F21
Left, F21
Right, F21
F23, Return and a beep
And that leads to a few questions:
1) What's with the the F20, F21 and F23 keycodes? What do they signify? It
would make some sense if the F## keystroke always preceded the usual keycode
(so the software could perhaps handle the star pad differently from the
SIP), but it's a real kludge if the F## keystroke follows the usual keycode.
2) Can I get rid of the beep? I tried setting AcceptsReturn both ways on the
textbox and that didn't seem to affect the beep.
3) What other controls support KeyDown detection?
4) Design question: I've got a tab control with 4 tab pages. The tab page of
interest to me has a bunch of buttons, combo boxes, trackbars, etc. There's
also a bunch of combo boxes and list views that are outside the entire tab
control. I don't need the SIP for any of these controls. I'd like to use the
Up/Down/Return keys from the star pad. What do you think about this
approach:
* deriving a class ("MyGizmo") from one of the controls that supports
KeyDown (probably not the TextBox since it beeps for Return)
* instantiating Gizmo on the tab page of interest
* setting the Gizmo invisible (or, if it must be visible in order to get
focus, then creating a 1-pixel screen representation)
* adding a handler to all the other screen controls' GotFocus event to send
the focus over to the Gizmo control
* adding a handler to the Gizmo KeyDown event; if the tab control's selected
tab page is the one I'm interested in, and the keycode is one of my special
keycodes, then do whatever needs to be done and mark the keycode as handled
Boy, I sure wish I had a form-level KeyPreview....
Thanks.
Richard Kucia