Results 1 to 5 of 5

Thread: KeyPress

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    Gloucestershire, England
    Posts
    301

    Post

    I cant seem to get Keypress to work.

    I have a form, when the user presses ESC I want an event to happen. I have tried

    Private Sub Form_KeyPress(KeyAscii As Integer)

    Keydown and Keyup, none of these seem to work. Is Form_.... the right place, or should it be somewhere else????

    My form is a MDIChild.


  2. #2
    Hyperactive Member
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    455

    Post

    Hello Rick,

    The keypress will only work for your form if it is an empty form.

    If you have components on your form I do think all of them heve to configured for your ESC key.

    Nice regards,

    michelle.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    Gloucestershire, England
    Posts
    301

    Post

    I thought about that, but its a bit long winded.

    I was wondering wether I could have an invisable button with an accelerator (short cut) key, but I`m not sure if its possible to implement shortcut keys with buttons. do you know if this is possible?


  4. #4
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    Set the keypreview property of the form to True, then you can use the form_keydown event to catch the escape key (and if you need to know what control has the focus, you can use ActiveControl( .Name ) )

    Hehe you replied while I replied... you can set the Cancel property of a commandbutton to true, but the button needs to be visible.

    [This message has been edited by Crazy D (edited 01-27-2000).]

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jan 2000
    Location
    Gloucestershire, England
    Posts
    301

    Post

    I know!, I got there first though. I have used the Keypreiew option, works a treat.
    Cheers


    [This message has been edited by Rick H (edited 01-27-2000).]

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