Discussion:
Try KeyDown or KeyPress event
(too old to reply)
WCyrek
2004-07-28 20:07:10 UTC
Permalink
look up those two funtions in the help docs

The KeyDown and KeyUp events are typically used to
recognize or distinguish between:

Extended character keys, such as function keys.


Navigation keys, such as HOME, END, PAGEUP, PAGEDOWN, UP
ARROW, DOWN ARROW, RIGHT ARROW, LEFT ARROW, and TAB.


Combinations of keys and standard keyboard modifiers
(SHIFT, CTRL, or ALT).


The numeric keypad and keyboard number keys.
The KeyDown and KeyUp events do not occur under the
following circumstances:

The user presses enter on a form with a command button
whose Default property is set to True.


The user presses esc on a form with a command button
whose Cancel property is set to True.
-----Original Message-----
Is there a way to detect if the alt key is pressed?
Using Word XP / 2003
.
Helmut Weber
2004-07-29 08:48:55 UTC
Permalink
Hi,
I have been playing with the following code
for quite a while, and keep wondering what
it is doing, without understanding almost nothing.
Private Declare Function GetKeyState Lib "user32" _
(ByVal vKey As Long) As Integer
Sub KeyState()
MsgBox GetKeyState(&HA4)
End Sub
I found this in a book: Const VK_LMENU = &HA4
Looks as if it stood for the left menu key.
But works with (left) alt key in this way:
Returns 1 if the alt key was pressed a first time,
and remembers it. That is, from now on
getkeystate returns 1, until left alt is pressed
a second time, from then on retirns 0,
like a toggle switch.
---
Greetings from Bavaria, Germany
Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word 2002, Windows 2000

Loading...