new KeyboardInput(options)
A KeyboardInput is an input device that will monitor the keystrokes on a specified DOM element and transmit those actions to the engines.
Parameters:
Name | Type | Argument | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
The device options. Properties
|
- Implements:
- Source:
Members
-
<readonly> element :Element
-
This value contains the element on which the DOM listeners have been bound.
Type:
- Element
- Source:
-
<readonly> keyMap :KeyMap
-
This value contains the current key map used to filter keys.
Type:
- KeyMap
- Source:
Methods
-
getState(port, code)
-
An engine will call this function to check the current state of a specified input. The function will return true if the input is currently active (pressed), and false otherwise.
Parameters:
Name Type Description port
number The input controller port.
code
number The input code.
- Implements:
- Source:
-
pollInputs()
-
An engine will call this function to inform the device that it should update the input state.
It means that the devices should never update the input state by themselves, but rather wait for the engine order. It is also important that the update is done synchronously, so that right after returning, the engines are able to call Input#getState.
- Implements:
- Source:
-
setCodeMap()
-
- Source:
-
setElement()
-
Change the element on which are bound the DOM listeners.
- Source:
-
setKeyMap(keyMap)
-
Set the key map that will be used to translate key codes into inputs.
Any old key that doesn't map to the same input anymore will be automatically released.
Parameters:
Name Type Description keyMap
KeyMap The new key map.
- Source: