Compartir a través de


KeyDown Event of the AxWindowsMediaPlayer Object

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

The KeyDown event occurs when a key is pressed.

[C#]
private void player_KeyDownEvent(
  object sender,
  _WMPOCXEvents_KeyDownEvent e
)

[Visual Basic]
Private Sub player_KeyDownEvent(  
  sender As Object, 
  e As _WMPOCXEvents_KeyDownEvent
) Handles player.KeyDownEvent

Event Data

The handler associated with this event is of type AxWMPLib._WMPOCXEvents_KeyDownEventHandler. This handler receives an argument of type AxWMPLib._WMPOCXEvents_KeyDownEvent, which contains the following properties related to this event.

Property Description
nKeyCode System.Int16Specifies which physical key is pressed. For possible values, see Remarks.
nShiftState System.Int16A bitfield 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. The shift argument indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed.

Remarks

The nKeyCode property specifies a physical key. The following tables show the possible values for the major keys on a standard keyboard.

Values for the main keys.

Key Value
A-Z 65-90
0-9 48-56
F1-F12 112-123
ESC 27
TAB 9
CAPS LOCK 20
SHIFT (left or right) 16
CTRL (left or right) 17
ALT (left or right) 18
SPACE 32
BACKSPACE 8
ENTER 13
Windows logo key, left 91
Windows logo key, right 92
Application key 93

Values for the number pad keys.

Key Value
0-9 96-105
NUM LOCK 144
DIVIDE (/) 111
MULTIPLY (*) 106
SUBTRACT (-) 109
ADD (+) 107
SEPARATOR (Enter) 108
DECIMAL (.) 110

Values for the navigation keys.

Key Value
INSERT 45
DELETE 46
HOME 36
END 35
PAGE UP 33
PAGE DOWN 34
UP ARROW 38
DOWN ARROW 40
LEFT ARROW 37
RIGHT ARROW 39

Requirements

Requirement Value
Version
Windows Media Player 9 Series or later
Namespace
AxWMPLib
Assembly
AxInterop.WMPLib.dll (AxInterop.WMPLib.dll.dll)

See also

AxWindowsMediaPlayer Object (VB and C#)