Detect Multiple key in Keypress event 
Author Message
 Detect Multiple key in Keypress event

Dear all,

           I want the keyascii parameter in keypress event to catch
multiple key combination.
I want to let user press Shift and G , then I will do something. How
can I detect the multiple
key for Shift and G. Something may be like  the following code:

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbShiftMask & vbKeyReturn Then
        MsgBox "hello"
    End If

End Sub



Tue, 28 Jun 2011 12:52:08 GMT  
 Detect Multiple key in Keypress event
hi,

Try using the KeyDown or KeyUp events instead.


Quote:
> Dear all,

>           I want the keyascii parameter in keypress event to catch
> multiple key combination.
> I want to let user press Shift and G , then I will do something. How
> can I detect the multiple
> key for Shift and G. Something may be like  the following code:

> Private Sub Form_KeyPress(KeyAscii As Integer)
>    If KeyAscii = vbShiftMask & vbKeyReturn Then
>        MsgBox "hello"
>    End If

> End Sub



Tue, 28 Jun 2011 12:57:49 GMT  
 Detect Multiple key in Keypress event
Private Sub Form_KeyDown(keycode As Integer, shift As Integer)
Private Sub Form_KeyUp(keycode As Integer, shift As Integer)

   "The shift argument is a bit field with the least-significant bits
corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT
key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively.
Some, all, or none of the bits can be set, indicating that some, all, or
none of the keys are pressed."

  Note that keycode values are not the same as keyascii
values.

Quote:
>            I want the keyascii parameter in keypress event to catch
> multiple key combination.
> I want to let user press Shift and G , then I will do something. How
> can I detect the multiple
> key for Shift and G. Something may be like  the following code:

> Private Sub Form_KeyPress(KeyAscii As Integer)
>     If KeyAscii = vbShiftMask & vbKeyReturn Then
>         MsgBox "hello"
>     End If

> End Sub



Tue, 28 Jun 2011 13:11:40 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. KeyPress event to detect Function Keys?

2. Detecting Keypress if Arrow Keys are pressed

3. Can't detect carriage return in keypress event

4. No DELETE key acknowledgement wih KeyPress event

5. "Delete" key, and KeyPress event

6. keypress event for DEL key

7. Help. Keypress event and DEL key

8. TAB key doesn't raise KeyPress event

9. TAB key doesn't raise KeyPress event

10. Why is TAB key trapped in Keypress event?

11. TAB key doesn't raise KeyPress event

12. KeyPress Event of the Tab Key ?

 

 
Powered by phpBB® Forum Software