Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Hey wassup y'all?

OK my Question,

when I use ascii to recognise a keypress, is there a way for VB to recognize the up, down, left and right keys??

It doesn't seem to recognise when they are pressed.




  • Hi there Yiay,

    When a user presses (KeyDown) or releases (KeyUp) a key, the KeyDown and KeyUp events occur. The KeyDown and KeyUp events receives all keystrokes. These events are most often used for extended character keys such as function keys, navigational keys, combination of keys with standard keyboard modifiers (such as the Shift key, Ctrl key, etc.) and distinguishing between the numeric keypad and regular number keys. There are a number of keys that do not cause the KeyDown and KeyUp events to occur, such as:

    The ENTER key if the form has a CommandButton control with the Default property set to True.

    The ESC key if the form has a CommandButton control with the Cancel property set to True.

    The TAB key.

    The KeyDown and KeyUp events can be used to determine if the SHIFT key was pressed by using the following two arguments: keycode and shift. Using these two arguments, you can determine which character to return, such as A or a.

    You can find more information on the KeyUp and KeyDown events in your Visual Basic 5.0 books online.

    I hope that this information helps, Yiay. I wish you the best of luck in all your programming ventures!



    Keenan Stewart (

    Learning Advisor,

    Microsoft Certified Technical Education Center

    Novell Authorized Online Training Provider


  • Erm, no it didn't really help, maybe I just couldn't make sense of it, or maybe it didn't answer the question but all I weanted to know is if there is a way for VB to recognise when the arrow keys are pressed.


  • There is a way. Use KeyDown Event and check when you need the KeyCode argument of the Event. Take these VB constants: vbKeyLeft(left arrow key), vbKeyRight(right arrow key), vbKeyUp(up arrow key) and vbKeyDown(down arrow key). I hope this is what you need.

  • It may be Anton yeah, but can you tell me how I might make it, for example, show form2 when I press the up key??



  • Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = vbKeyRight Then Form2.Show

    End Sub

  • Use the following procedure:

    Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)

    If KeyCode = vbKeyUp Then Form2.Show

    End Sub

  • Justin BibJustin Bib USAMember Posts: 0

    _____ \ \ free video tutorials and ebooks about // C#, Visual Basic, Assembly, PHP, Delphi, Visual Basic .NET, Objective-C, MATLAB, Perl, C, C++, Java, PL/SQL, JavaScript, Scratch, Python, Swift, R, Ruby, Go Prolog, Lisp, Fortran, Bash, Dart, Erlang, LabVIEW, Kotlin, F#, Apex, Alice, ABAP, Crystal, Transact-SQL, Clojure, FoxPro, COBOL, Lua, SAS, Hack, Ada, Scheme, Logo, VBScript, Rust, Scala, Awk, Julia, D, ML // ________

Sign In or Register to comment.