Skip to main content
The Deno 2 Release Candidate is here
Learn more
Module

x/lunchbox/src/handlers.ts>Key

Component Library 🍱 for Deno πŸ¦• Fresh πŸ‹
Latest
variable Key
import { Key } from "https://deno.land/x/lunchbox@v1.0.1/src/handlers.ts";

Key

A utility object to easily check if certain keys are being pressed during onkeydown events. This object provides methods to check for common special keys like Enter, Backspace, Shift, etc., and also includes methods to handle modifier keys specific to different operating systems (Windows and macOS).

Each method takes a KeyboardEvent object and returns a boolean indicating whether the corresponding key is being pressed.

type

{ Enter: (ev: KeyboardEvent) => unknown; Backspace: (ev: KeyboardEvent) => unknown; Shift: (ev: KeyboardEvent) => unknown; Escape: (ev: KeyboardEvent) => unknown; Tab: (ev: KeyboardEvent) => unknown; Control: (ev: KeyboardEvent) => unknown; Meta: (ev: KeyboardEvent) => unknown; Alt: (ev: KeyboardEvent) => unknown; Spacebar: (ev: KeyboardEvent) => unknown; Up: (ev: KeyboardEvent) => unknown; Down: (ev: KeyboardEvent) => unknown; Left: (ev: KeyboardEvent) => unknown; Right: (ev: KeyboardEvent) => unknown; CtrlWin: (ev: KeyboardEvent) => unknown; WindowsKey: (ev: KeyboardEvent) => unknown; CtrlMac: (ev: KeyboardEvent) => unknown; Command: (ev: KeyboardEvent) => unknown; mod1: (ev: KeyboardEvent) => unknown; mod2: (ev: KeyboardEvent) => unknown; }