By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,039 Members | 1,824 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,039 IT Pros & Developers. It's quick & easy.

Trapping for Ctrl or Alt Key?

P: n/a
Is there a way to trap for a Ctrl or Alt key when typing in a field? I want
to be able to perform an action when the user types Ctl+A or Alt+A or
whatever. I noticed the KeyDown function allows you to check for the state
of the Shift key. I'm looking for something like that for Ctrl and/or Alt.
Thank you.
Oct 5 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Phil Reynolds" <ph*******@msn.comwrote in message
news:oc***************@nlpi061.nbdc.sbc.com...
Is there a way to trap for a Ctrl or Alt key when typing in a field? I
want to be able to perform an action when the user types Ctl+A or Alt+A or
whatever. I noticed the KeyDown function allows you to check for the state
of the Shift key. I'm looking for something like that for Ctrl and/or Alt.
Thank you.
In the OnKeyDown event proc:

Dim intCtrlDown As Integer

intCtrlDown = (Shift And acCtrlMask) 0
If intCtrlDown And KeyCode = vbKeyA Then
MsgBox "Ctrl-A was pressed"
End If

You also have constants for the other shift keys:

acAltMask
scShiftMask

To obtain KeyCode constants, search for 'keycode' in the object browser.


Oct 5 '07 #2

P: n/a
Cool. Thanks!

"Stuart McCall" <sm*****@myunrealbox.comwrote in message
news:fe*******************@news.demon.co.uk...
"Phil Reynolds" <ph*******@msn.comwrote in message
news:oc***************@nlpi061.nbdc.sbc.com...
>Is there a way to trap for a Ctrl or Alt key when typing in a field? I
want to be able to perform an action when the user types Ctl+A or Alt+A
or whatever. I noticed the KeyDown function allows you to check for the
state of the Shift key. I'm looking for something like that for Ctrl
and/or Alt. Thank you.

In the OnKeyDown event proc:

Dim intCtrlDown As Integer

intCtrlDown = (Shift And acCtrlMask) 0
If intCtrlDown And KeyCode = vbKeyA Then
MsgBox "Ctrl-A was pressed"
End If

You also have constants for the other shift keys:

acAltMask
scShiftMask

To obtain KeyCode constants, search for 'keycode' in the object browser.


Oct 5 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.