Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

HTMLWindowEvents4::onkeydown Event

New for Internet Explorer 9

[This documentation is preliminary and is subject to change.]

Fires when the user presses a key.

Syntax


void onkeydown(
    IHTMLEventObj *pEvtObj
);

Parameters

pEvtObj
[in] Pointer to an IHTMLEventObj interface for the current event. This is the same interface returned from IHTMLWindow2::event.

Return Value

No return value.

Event DISPID


DISPID_HTMLWINDOWEVENTS4_ONKEYDOWN

The DISPID for this event is defined in mshtmdid.h. Use this value to identify the event handler when implementing IDispatch::Invoke.

Event Information

Bubbles Yes
Cancels Yes
To invoke Press any keyboard key.
Default action Returns a number specifying the keyCode of the key that was pressed.

Event Object Properties

The IHTMLEventObj interface contains additional information about the current event. When the onkeydown event is fired, you can use the IHTMLWindow2::event property to retrieve an IHTMLEventObj interface. To obtain an alternate interface pointer such as IHTMLEventObj2 or IHTMLEventObj3, call QueryInterface on the object.

Available Properties

IDOMKeyboardEvent::key New for Internet Explorer 9  Gets the key identifier of a key that is pressed.
IHTMLEventObj::keyCode Sets or retrieves the Unicode key code associated with the key that caused the event.
IDOMKeyboardEvent::location New for Internet Explorer 9  Gets the location of a key on the keyboard or device.
IDOMKeyboardEvent::repeat New for Internet Explorer 9  Gets a value that indicates whether a key was pressed and held.

Refer to the specific event object for additional event properties.

Remarks

As of Microsoft Internet Explorer 4.0, the HTMLWindowEvents4::onkeydown event fires for the following keys:

  • Editing: DELETE, INSERT
  • Function: F1 - F12
  • Letters: A - Z (uppercase and lowercase)
  • Navigation: HOME, END, LEFT ARROW, RIGHT ARROW, UP ARROW, DOWN ARROW
  • Numerals: 0 - 9
  • Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~
  • System: ESC, SPACEBAR, SHIFT, TAB

As of Internet Explorer 5, the event also fires for the following keys:

  • Editing: BACKSPACE
  • Navigation: PAGE UP, PAGE DOWN
  • System: SHIFT+TAB

As of Internet Explorer 5, this event can be canceled for the following keys and key combinations by specifying event.returnValue=false:

  • Editing: BACKSPACE, DELETE
  • Letters: A - Z (uppercase and lowercase)
  • Navigation: PAGE UP, PAGE DOWN, END, HOME, LEFT ARROW, RIGHT ARROW, UP ARROW, DOWN ARROW
  • Numerals: 0 - 9
  • Symbols: ! @ # $ % ^ & * ( ) _ - + = < [ ] { } , . / ? \ | ' ` " ~
  • System: SPACEBAR, ESC, TAB, SHIFT+TAB

You can cancel all keys that fire the HTMLWindowEvents4::onkeydown event in HTML Applications, including most accelerator keys, such as ALT+F4.

In Internet Explorer 4.0, you cannot cancel the HTMLWindowEvents4::onkeydown event, but you can use the HTMLWindowEvents4::onkeypress event to cancel keyboard events.

See Also

HTMLWindowEvents4::onkeyup

Community Additions

Show:
© 2015 Microsoft