Word VBA >> Try KeyDown or KeyPress event

by WCyrek » Thu, 29 Jul 2004 04:07:10 GMT

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
>.
>


Similar Threads

1. using keypress/keydown events for an outlook COMaddin VB6

i'm trying to assign a key throughout a project for comaddin for outlook.  
I'm thinking  i can put it in the inithandler of the project, but that 
doesn't work.  Can i capture keyevents in Outlook?  Using the following code: 

Private Sub InitHandler_KeyDown(KeyCode As Integer, Shift As Integer)

If KeyCode = 120 Then MsgBox "DFSDSFDYou pressed the F9 key."
If KeyCode = 32 Then MsgBox "DFSDSFDYou pressed the space key."

End Sub

2. not able to trap Enter key (keypress or keydown) in vb.net datagrid - .NET Windows Forms

3. EnterKey not recogized during KeyPress, KeyDown (VB6,Win98se)

Here's the scenario:
I want to have an event trigerred and be able to 
distinguish between the enter-key and the numericpad enter 
key. [VB6,Win98se, HP desktop, standard 101-keyboard]
 
Here's the problem:
EnterKey not recognized during KeyPress, KeyDown or KeyUp.
I've set the KeyPreview to True in order to capture the 
keyboard first before other control events. I've set up 
events for Form_KeyPress,Form_KeyDown, and Form_KeyUp.
I've tried checking the KeyCode and the KeyAscii values. 
None of these events are triggered when either the "enter" 
key or the NumPad "enter" (keyseparator, executor) buttons 
are pressed.
Anyone have any clues?
[Hardware problem, I know :-)]

4. Keydown, keypress function keys - Visual Basic/VB

5. Diff between KeyPress and KeyDown

6. KeyPress Event & MouseDown event

7. Adding textboxes runtime and controlling KeyDown Event

Hii everybody,
I want to add a new Textbox to my Userform runtime.If the user press teh 
Enter Key on this runtime added Textbox then I want to add another Textbox 
below the last want. And again on Enter Key I want to do that all again.
Adding a Textbox Runtime is OK.But I cannot controll the Keydown Event of 
this runtime added Textbox.

Does anyone have any idea ?

Thanks in advance

Suad Candir


8. capture keydown/press events in a user form - Word VBA