Skip to content
pixi-silk
GitHub repository
Entry point

pixi-silk/ui/keys

Shared keyboard state: isKeyDown, modifier checks, onKey, isTypingTarget.

import { altDown, isKeyDown, isTypingTarget, modDown } from 'pixi-silk/ui/keys';

Functions#

FunctionDescription
altDownTrue while either Alt / Option is down.
isKeyDownTrue while the key with this KeyboardEvent.code is down (e.g. ShiftLeft, KeyR, Space).
isTypingTargetTrue when a key event comes from an input, textarea, select or content-editable element. The keys then belong to the field and not to the canvas.
modDownTrue while either Control or Meta (Command) is down.
onKeyCalls fn on every key press and release on window. Auto-repeat presses are skipped. When the window loses focus, every held key gets a synthetic release. Returns the unsubscribe function.
shiftDownTrue while either Shift is down.