photonui.KeyboardManager Class
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.WidgetAny PhotonUI Widget (optional).
-
element
HTMLElementAny HTML element (optional).
-
params
ObjectAn object that can contain any property of the widget (optional).
Item Index
Methods
Methods
__onWindowBlur
()
private
Called when the window loose focus
_bindEvent
-
id
-
element
-
evName
-
callback
-
[options]
Parameters:
_callCallbacks
-
wEvent
-
params
_checkEvent
-
event
Check the validity of the keyboard event
Parameters:
-
event
KeyboardEventThe keyboard event
Returns:
_initKeyCache
()
private
Create the key correspondance cache for basic touches
_keyFromEvent
-
event
Get the key name from a native keyboard event
Parameters:
-
event
KeyboardEventThe keyboard event
Returns:
_updateEvents
()
private
Bind events on the HTML Element.
_updateProperties
-
properties
Parameters:
-
properties
ArrayThe properties to update.
destroy
()
isKeyPressed
-
key
Check if a specific key is currently pressed.
Parameters:
-
key
StringThe key name
Returns:
isKeyReleased
-
key
Check if a specific key is currently released.
Parameters:
-
key
StringThe key name
Returns:
registerCallback
-
id
-
wEvent
-
callback
-
thisArg
Properties
__events
Object
private
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
safe
Boolean
Disable the keyboard manager callbacks when focusing a input field-like element.
Default: true