Catching keypresses (cursor keys)

who shot Mr Burns

  • Mrs Burns

    Votes: 0 0.0%
  • Maggie

    Votes: 0 0.0%
  • Homer

    Votes: 0 0.0%
  • Moe

    Votes: 0 0.0%

  • Total voters
    0

homer2002

Registered User.
Local time
Today, 13:43
Joined
Aug 27, 2002
Messages
152
Hi

I know its easy to catch keypresses, but how do you catch the cursor keys.

Am I correct in assuming they dont give any ascii value like other keys?
 
homer2002 said:
Hi

I know its easy to catch keypresses, but how do you catch the cursor keys.
What is a cursor key? I have never seen a keyboard key labeled "Cursor".

Check the help files for the Keycode Constants for a complete listing of all keyboard codes to use in VBA. The Keycode Constant for the down arrow key is vbKeyDown. This code snipet for the KeyDown event tests if the user presses an arrow key...
Code:
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
    Select Case KeyCode
        Case vbKeyLeft, vbKeyUp, vbKeyRight, vbKeyDown
        KeyCode = 0
        MsgBox "You pressed an arrow key, that key has been disabled!" 'for testing
    End Select

End Sub
HTH
 
ghudson said:
What is a cursor key? I have never seen a keyboard key labeled "Cursor".

Really? I've always called them cursor keys (over 20 years). You are right, though, in that they are the arrow keys.
 

Users who are viewing this thread

Back
Top Bottom