-
Hi there, this is a pretty simple problem i think being that i want to detect when an arrow key is pressed, but the system doesn't seem to register them as key presses.
I have tried putting a function in the keypress function, to output the ascii code for the last keypress, but it doesn't register when an arrow is pressed, also what do VbKeyLeft/right/up/down denote?
Thanks for any help, Piers
-
Hello Piers,
Try KeyDown
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
MsgBox Str(KeyCode) & Str(Shift)
End Sub
Good luck,
Michelle.
-
Use the keydown event
up keycode = 38
down keycode = 40
right keycode = 39
left keycode = 37
-
erm, it seems that neither of these work..
i don't know why, but they just don't, ok the situation is that i'm using the flexgrid control and when a user moves around the grid with the arrow keys, i want to know about it..
the keypress and keydown events don't even get triggered when i press the arrow keys, they only occur when i type anything else..
Any other suggestions?
Thanks Piers.
-
I just did a little testing and guess what. Your right, the Arrow Keys do not register in a FlexGrid. They don't even get intercepted by the Form if you set the KeyPreview property to True! But there is good news, there are two events that are triggered whenever a cell receives focus:
SelChange and RowColChange
(raised in that order)
However, these are also called if the user clicks on a differnet cell, but this may be what you're looking for.
Ciao for now.
-
Thanks for claifying that for me, i thought there my be something wrong with my machine :eek: , i've had a look at those two funcions you stated, and they look pretty useful to me, thanks.
Piers