Keyboard
Keyboard
We implemented a built-in keyboard listener to make one central place where keyboard events can be accessed (without adding a listener yourself).
The following methods are available on map.pm.Keyboard:
| Method | Returns | Description |
|---|---|---|
getLastKeyEvent(type = 'current') | Object | Returns the last event. Also keydown and keyup can be passed, to get the specific one. |
| getPressedKey() | String | Returns the current pressed key. KeyboardEvent.key |
| isShiftKeyPressed() | Boolean | Returns true if the Shift key is currently pressed. |
| isAltKeyPressed() | Boolean | Returns true if the Alt key is currently pressed. |
| isCtrlKeyPressed() | Boolean | Returns true if the Ctrl key is currently pressed. |
| isMetaKeyPressed() | Boolean | Returns true if the Meta key is currently pressed. |
The following events are available on a map instance:
| Event | Params | Description | Output |
|---|---|---|---|
| pm:keyevent | e | Fired when keydown or keyup on the document is fired. eventType = keydown / keyup, focusOn = document / map | event, eventType, focusOn |