Results 1 to 4 of 4

Thread: [RESOLVED] Fire a event with a key combination

  1. #1

    Thread Starter
    Hyperactive Member Chathura's Avatar
    Join Date
    Nov 2005
    Location
    Sri Lanka
    Posts
    345

    Resolved [RESOLVED] Fire a event with a key combination

    Hi!
    I want to call some functions when a combination of key is pressed. But I don't know what is the event that I can track this combination.

  2. #2
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Fire a event with a key combination

    Trap KeyDown event, and you will also need to set the KeyPreview property of the form true.

    Actually the information provided is too little. If you can elaborate as to what you are actually looking for it would be easier to help.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

  3. #3
    Fanatic Member
    Join Date
    Aug 2005
    Location
    South Africa
    Posts
    760

    Re: Fire a event with a key combination

    If you want to be able to trap the key sequence even when your form does not have focus you should register a HotKey or use the GetAsyncKeystate API to detect which keys are being pressed
    If I helped you out, please consider adding to my reputation!

    -- "The faulty interface lies between the chair and the keyboard" --

    VB6 Programs By Me:
    ** Dictionary, Thesaurus & Rhyme-Generator In One ** WMP Recent Files List Editor ** Pretty Impressive Clock ** Extract Firefox History **

  4. #4
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: Fire a event with a key combination

    Set the KeyPreview property of the Form to true. And then use this code
    VB Code:
    1. Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    2.     If KeyCode = vbKeyS And Shift = 2 Then
    3.         'call your save function here
    4.     End If
    5. End Sub
    Remember you will have to call the Save Function code from within the If Condition.
    Use [code] source code here[/code] tags when you post source code.

    My Articles

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