API Docs for: 1.8.0
Show:

photonui.KeyboardManager Class

Extends photonui.Base
Module: NonVisual
Parent Module: PhotonUI

Manage document-wide keyboard events.

wEvents:

  • key-down:

    • description: When a key is pushed (event launched just once until key is released).
    • callback: function(manager, kstate)
  • key-up:

    • description: When a key is released.
    • callback: function(manager, kstate)
  • key-hold:

    • description: When the last key pressed is held down.
    • callback: function(manager, kstate)

kstate:

A snapshot of the keyboard state when the event occured.

{
    event: <Object>,       // The original js event
    action: <String>,      // The event name (key-down/up, key-hold)
    keys: <String>,        // The object of active keys
    key: <String>,         // User-friendly key name
}

Constructor

photonui.KeyboardManager

(
  • element
  • element
  • params
)

Parameters:

  • element photonui.Widget

    Any PhotonUI Widget (optional).

  • element HTMLElement

    Any HTML element (optional).

  • params Object

    An object that can contain any property of the widget (optional).

Methods

__onDocumentKeyDown

(
  • event
)
private

Used to grab all keyboard events

Parameters:

__onDocumentKeyUp

(
  • event
)
private

Used to grab all keyboard events

Parameters:

__onWindowBlur

() private

Called when the window loose focus

_bindEvent

(
  • id
  • element
  • evName
  • callback
  • [options]
)
private

Inherited from photonui.Base: src/base.js:229

Javascript event binding (for internal use).

Parameters:

  • id String
    An unique id for the event.
  • element DOMElement
    The element on which the event will be bind.
  • evName String
    The event name (e.g. "mousemove", "click",...).
  • callback Function
    The function that will be called when the event occured.
  • [options] Object optional
    options for addEventListener

_callCallbacks

(
  • wEvent
  • params
)
private

Inherited from photonui.Base: src/base.js:292

Call all callbacks for the given wEvent. NOTE: the first argument passed to the callback is the current widget. NOTEĀ²: if the thisArg of the callback is null, this will be binded to the current widget.

Parameters:

  • wEvent String
    The widget event.
  • params Array
    Parametters that will be sent to the callbacks.

_checkEvent

(
  • event
)
Boolean private

Check the validity of the keyboard event

Parameters:

Returns:

_checkFocus

() Boolean private

Check if the user has not focused an input element

Returns:

_dump

() Object private

Take a snapshot of the KeyboardManager

Returns:

_initKeyCache

() private

Create the key correspondance cache for basic touches

_keyFromEvent

(
  • event
)
String private

Get the key name from a native keyboard event

Parameters:

Returns:

_registerWEvents

(
  • wEvents
)
private

Inherited from photonui.Base: src/base.js:276

Register available wEvent.

Parameters:

_unbindEvent

(
  • id
)
private

Inherited from photonui.Base: src/base.js:257

Unbind javascript event.

Parameters:

  • id String
    The id of the event.

_updateEvents

() private

Bind events on the HTML Element.

_updateProperties

(
  • properties
)
deprecated private

Inherited from photonui.Base: src/base.js:209

Force the update of the given properties. This method is deprecated. One should use '@photonui-update' abitbol's annotation on concerned properties.

Parameters:

  • properties Array
    The properties to update.

destroy

()

Inherited from photonui.Base: src/base.js:157

Destroy the class.

isKeyPressed

(
  • key
)
Boolean

Check if a specific key is currently pressed.

Parameters:

Returns:

isKeyReleased

(
  • key
)
Boolean

Check if a specific key is currently released.

Parameters:

Returns:

registerCallback

(
  • id
  • wEvent
  • callback
  • thisArg
)

Inherited from photonui.Base: src/base.js:169

Register a callback for any PhotonUI/Widget event (called wEvent). Callback signature: function (Object(Base/Widget) [, arg1 [, arg2 [, ...]]])

Parameters:

  • id String
    An unique id for the callback.
  • wEvent String
    the PhotonUI/Widget event name.
  • callback Function
    The callback function.
  • thisArg Object
    The value of this (optionnal, default = current widget).

removeCallback

(
  • id
)

Inherited from photonui.Base: src/base.js:193

Remove a registered callback.

Parameters:

  • id String
    The id of the callback.

Properties

__callbacks

Object private

Inherited from photonui.Base: src/base.js:142

Object containing references to registered callbacks.

__event

Object private

Last event object.

Default: null

__events

Object private

Inherited from photonui.Base: src/base.js:132

Object containing references javascript events binding (for widget internal use).

__key

String private

Last key concerned.

Default: null

__keyCache

Array private

KeyCode correspondance to key name.

__keyCodeCache

Array private

Key name correspondance to key code.

action

String

The action:

  • "key-down"
  • "key-up"
  • "key-hold"

data

Object

Inherited from photonui.Base: src/base.js:113

Arbitrary data

Default: {}

element

HTMLElement

The HTML Element on which the events are binded.

NOTE: If a photonui.Widget object is assigned to this property, its HTML Element will be automatically assigned to the property instead.

Default: null

keys

Object private

The currently active keys.

Default: {}

noPreventDefault

Boolean

Disable concerned events default actions.

Default: false

safe

Boolean

Disable the keyboard manager callbacks when focusing a input field-like element.

Default: true