Help Center

Local Navigation

Object: KeyboardEvent

Availability

BlackBerry® Device Software version 4.6 or later

Extends

UIEvent

The KeyboardEvent object extends the UIEvent object and represents an event generated by the BlackBerry® device keyboard. It provides specific contextual information associated with keyboard devices. Each keyboard event references a key using an identifier. Keyboard events are commonly directed at the element that has the focus.

To create an instance of a KeyboardEvent, you must invoke Document.createEvent() with an input parameter of ”KeyboardEvent”.

Keyboard event types

Event type

Bubbles

Cancelable

Description

keydown

yes

yes

Occurs when a key is pressed while the pointer is over an element.

This event type includes the following context information:

  • KeyboardEvent.altKey
  • KeyboardEvent.ctrlKey
  • KeyboardEvent.keyIdentifier
  • KeyboardEvent.keyLocation
  • KeyboardEvent.metaKey
  • KeyboardEvent.shiftKey
  • UIEvent.view

keypress

yes

yes

Occurs immediately after a keydown event. This event does not repeat.

This event includes the following context information:

  • KeyboardEvent.altKey
  • KeyboardEvent.ctrlKey
  • KeyboardEvent.keyIdentifier
  • KeyboardEvent.keyLocation
  • KeyboardEvent.metaKey
  • KeyboardEvent.shiftKey
  • UIEvent.view

keyup

yes

yes

Occurs when a key is released while the pointer is over an element.

This event type includes the following context information:

  • KeyboardEvent.altKey
  • KeyboardEvent.ctrlKey
  • KeyboardEvent.keyIdentifier
  • KeyboardEvent.keyLocation
  • KeyboardEvent.metaKey
  • KeyboardEvent.shiftKey
  • UIEvent.view

KeyboardEvent properties

Property name

Type

Description

Status

Support level

Availability

altKey

boolean

Returns true if the ALT key is pressed or if the ALT key is locked.

read only

DOM 3 Events

4.6 or later

ctrlKey

boolean

Returns false. BlackBerry® devices have no CTRL key.

read only

DOM 3 Events

4.6 or later

keyCode

int

Returns the key code associated with the key in this event.

read only

Not part of any standard.

4.6 or later

keyIdentifier

String

Returns the identifier of the key.

read only

DOM 3 Events

4.6 or later

keyLocation

int

Returns a value of DOM_KEY_LOCATION_STANDARD.

read only

DOM 3 Events

4.6 or later

metaKey

boolean

Returns false. BlackBerry devices have no Meta key.

read only

DOM 3 Events

4.6 or later

shiftKey

boolean

Returns true if the SHIFT key is pressed.

read only

DOM 3 Events

4.6 or later

KeyboardEvent methods

Method name

Description

Support level

Availability

getModifierState()

Checks the state of a modifier key.

DOM 3 Events

4.6 or later

initKeyboardEvent()

Initializes the value of a KeyboardEvent.

DOM 3 Events

4.6 or later

initKeyboardEventNS()

Initializes the value of a KeyboardEvent with the given namespace URI.

DOM 3 Events

4.6 or later

Previous topic: Object: EventException

Was this information helpful? Send us your comments.