Results 1 to 3 of 3

Thread: trapping the arrow keys

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 1999
    Posts
    1

    Post

    I need to know when an arrow key has been pressed but I can't locate the code to use for trapping them.

  2. #2
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926

    Post

    If you want to know if an arrow key is pressed for one control, you can use the KeyDown event of the specific control. If you want to know this for the complete form, set the KeyPreview Property of the form to True and use the form's KeyDown event. The KeyCode paramter tells you which key has been pressed.
    Left arrow : KeyCode = 37
    Up arrow : KeyCode = 38
    Right arrow : KeyCode = 39
    Down arrow : KeyCode = 40

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    Rather than use hard-coded "magic numbers" like 37, 38, etc., use the built-in vbKey... constants instead. For example vbKeyLeft has a value of 37.

    ------------------
    Marty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width