Skip to content
pixi-silk
GitHub repository
Function

onKey

import { onKey } from 'pixi-silk/ui/keys';
function onKey(fn: (code: string, down: boolean, e: KeyboardEvent) => void): () => void;

Calls 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.

Parameters#

ParameterType
fn(code: string, down: boolean, e: KeyboardEvent) => void

Returns#

() => void