Constructor
new Action(name)
Creates a named digital action. Usually created through Actions.bindKey()
or Actions.bindButton(). Names and keys are matched without regard to case.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Action name, such as "JUMP". |
- Source:
Throws:
-
If the name is not a non-empty string.
- Type
- TypeError
Members
(readonly) justPressed :boolean
Whether the action became held in the current update.
Type:
- boolean
- Source:
(readonly) justReleased :boolean
Whether the last held binding was released in the current update.
Type:
- boolean
- Source:
(readonly) name :string
The normalized action name.
Type:
- string
- Source:
(readonly) pressed :boolean
Whether any binding is held in the current update.
Type:
- boolean
- Source:
Methods
bindButton(button) → {rune.input.Action}
Adds a gamepad button binding, ignoring duplicates.
Parameters:
| Name | Type | Description |
|---|---|---|
button |
number | Non-negative integer button ID. |
- Source:
Throws:
-
-
If the button ID is not a non-negative finite integer.
- Type
- RangeError
-
-
-
If the action is disposed.
- Type
- Error
-
Returns:
This action.
- Type
- rune.input.Action
bindKey(key) → {rune.input.Action}
Adds a keyboard binding, ignoring duplicates. Unknown key names read as released.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | Keyboard key name, such as "SPACE". |
- Source:
Throws:
-
-
If the key is not a non-empty string.
- Type
- TypeError
-
-
-
If the action is disposed.
- Type
- Error
-
Returns:
This action.
- Type
- rune.input.Action
clear() → {undefined}
Removes all bindings. Any held action is released on the next update.
- Source:
Returns:
- Type
- undefined
reset() → {undefined}
Clears held and edge states without changing bindings or generating a release.
- Source:
Returns:
- Type
- undefined
unbindButton(button) → {boolean}
Removes a gamepad binding. State changes are sampled on the next update.
Parameters:
| Name | Type | Description |
|---|---|---|
button |
number | Button ID. |
- Source:
Returns:
Whether a binding was removed.
- Type
- boolean
unbindKey(key) → {boolean}
Removes a keyboard binding. State changes are sampled on the next update.
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | Key name. |
- Source:
Returns:
Whether a binding was removed.
- Type
- boolean