new MicrogameKeyboard()
Keyboard bindings.
Because the Keyboard API is still experimental, we're just going to use standard oninput stuff.
- Source:
Extends
Members
allKeysDown
Set of keys used across all MicrogameKeyboards to list all keys currently being pressed.
Set in module:input~MicrogameKeyboard#interruptInputUp and module:input~MicrogameKeyboard#interruptInputDown.
Used only in module:optionsmanager.
- Source:
baseBindings
Bindings to allow input for no matter what.
- Inherited From:
- Source:
bindings
A map of maps.
The bindings to use for each game (or all of them).
- Inherited From:
- Source:
- To Do:
-
- FIX to be a map for all games.
(private) currBinding
The current set of bindings we’re using from this.bindings. Set in module:input~MicrogameInput#gameInputStartUpdate based on the current game being played.
- Inherited From:
- Source:
(private) gameLocation
The HREF of the current game loaded. Used to ignore key presses if a keyboard event is targeting the gameLocation.
- Source:
(private) keysToDown
Set of keys that are currently being pressed. Accessed through module:input~MicrogameKeyboard#getAnyInput and module:input~MicrogameKeyboard#getInput.
- Source:
(private) stateTracker
What keys/controls are currently being used. Used in module:input~MicrogameInput#update exclusively.
- Inherited From:
- Source:
Methods
gameStartInputUpdate(game)
Called whenever a game starts. Resets the module:input~MicrogameKeyboard#interruptInput Down and Up bindings. Also sets module:input~MicrogameKeyboard#gameLocation.
Parameters:
Name | Type | Description |
---|---|---|
game |
string | module:gameloader~GameLoader#game |
- Overrides:
- Source:
getAnyInput() → {object}
- Source:
Returns:
{control: key, type: MicrogameKeyboard} being pressed if it detects any input. null otherwise.
- Type
- object
getInput(control) → {boolean}
Parameters:
Name | Type | Description |
---|---|---|
control |
string | The key code that we’re checking for |
- Source:
Returns:
Is the key code that we’re checking for being pressed?
- Type
- boolean
(private) interruptInputDown()
When any key is pressed, check to see if it’s a baseBinding (i.e., an allowed keyboard press). If so, press it. If not, add it to the list of keys to be queried for input (module:input~MicrogameKeyboard#keysToDown).
- Source:
- To Do:
-
- Fix to work so that you can send keys in place of the standard arrows.
interruptInputUp()
module:input~MicrogameKeyboard#interruptInputDown, but for when keys are released. And so delete from module:input~MicrogameKeyboard#keysToDown.
- Source:
update()
Called by MicrogameInputManager. Updates module:input~MicrogameInput#stateTracker based on inputs it detects.
- Inherited From:
- Source:
Returns:
The keys that we're going to be pressing based on our recieved inputs.