Howdy, Stranger!

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

Categories

How to make key shortcuts?

JimmyMan99JimmyMan99 Member Posts: 21
[b][red]This message was edited by JimmyMan99 at 2002-9-26 22:46:46[/red][/b][hr]
Hi. Ive just made a small program that works with a small database (my cd database) and i have many buttons there like move to next record, previous record, last first add a new one, delete and few more. Id like to make key shourtcuts, so that i dont have to click on the buttons if i want to navigate. For example "END" would move to the end of the database, "PAGE UP" would move 10 records up.
I know u can have keyboard shortcuts if u have a caption like this "&Add". In this case pressing ALT+A will activate the button. But what if i want to use END button or PAGE UP, or simply ARROW left or right ? The only way i could make it is to create _KeyPress events for all the buttons on the form, which calls a sub that will process the key and perform whatever action needed. Is there an easier way to do it or thats the only way? And it still doesnt let me work with ARROW keys, PAGE down etc
Thank you
James R.


Comments

  • KDivad LeahcimKDivad Leahcim Member Posts: 3,948
    : [b][red]This message was edited by JimmyMan99 at 2002-9-26 22:46:46[/red][/b][hr]
    : Hi. Ive just made a small program that works with a small database (my cd database) and i have many buttons there like move to next record, previous record, last first add a new one, delete and few more. Id like to make key shourtcuts, so that i dont have to click on the buttons if i want to navigate. For example "END" would move to the end of the database, "PAGE UP" would move 10 records up.
    : I know u can have keyboard shortcuts if u have a caption like this "&Add". In this case pressing ALT+A will activate the button. But what if i want to use END button or PAGE UP, or simply ARROW left or right ? The only way i could make it is to create _KeyPress events for all the buttons on the form, which calls a sub that will process the key and perform whatever action needed. Is there an easier way to do it or thats the only way? And it still doesnt let me work with ARROW keys, PAGE down etc
    : Thank you
    : James R.
    :
    :
    :

    Set the form's KeyPreview property to True.
    Don't use _KeyPress, use _KeyDown. Place this code in Form_KeyDown.
    [code]
    Select Case KeyCode
    Case vbKeyLeft
    'Left arrow
    Case vbKeyPageDown
    'Page down
    End Select
    [/code]
    Look for KeyCode Constants in the help file to get the full list of keys.

    KeyPreview allows the form to recieve all key events before the controls do. This is a handy way to do just what you want.
  • Andre YoungAndre Young USAMember Posts: 0

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

Sign In or Register to comment.