473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Trapping for Ctrl or Alt Key?

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
2 10584
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: David Gray | last post by:
Greetings all, Quick newbie type question: I would like to be able to trap non-numerical data entered into a textbox via CTRL+C and/or Shift+Insert. I realise that this data can be...
4
by: Wugi | last post by:
I'm trying to find an equivalent of key-event trapping which is easy in QBasic. Several of my programs build up a geometric figure with two parameter line families, eg with two nested for..next...
0
by: Otie | last post by:
Hello, I have an MDI application with 50 different forms. I want to be able to recognize key strokes such as ALT-1, CTRL-P, etc. from anywhere within my application, no matter what form has the...
8
by: Mike Maxwell | last post by:
<vent> I see there has been traffic over the years on this gripe, so just let me vent my frustration, and add another reason why 'exit' (or possibly exit() or quit() or halt() or some such) should...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
13
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
12
by: Wurm | last post by:
Hi all, Got a little problem with a lib that I'm working on. First of all, the problem is that the lib that I have makes connections to DirectSound, and has a host of custom built sound related...
2
by: Captain Nemo | last post by:
I'm still using Office 2000 myself, but some of my clients have Office 2003. I've recently added a piece of code to create an instance of Word, open a document, fill in the blanks and become...
9
by: 47computers | last post by:
Pretty new to PHP, I recently started learning about error trapping. As of right now, I include the following into a page in my website: -------BEGIN PASTE-------- error_reporting(E_ERROR |...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.