Skip to main content

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:

MethodReturnsDescription
getLastKeyEvent(type = 'current')ObjectReturns the last event. Also keydown and keyup can be passed, to get the specific one.
getPressedKey()StringReturns the current pressed key. KeyboardEvent.key
isShiftKeyPressed()BooleanReturns true if the Shift key is currently pressed.
isAltKeyPressed()BooleanReturns true if the Alt key is currently pressed.
isCtrlKeyPressed()BooleanReturns true if the Ctrl key is currently pressed.
isMetaKeyPressed()BooleanReturns true if the Meta key is currently pressed.

The following events are available on a map instance:

EventParamsDescriptionOutput
pm:keyeventeFired when keydown or keyup on the document is fired. eventType = keydown / keyup, focusOn = document / mapevent, eventType, focusOn