UNPKG

@liveblocks/react-ui

Version:

A set of React pre-built components for the Liveblocks products. Liveblocks is the all-in-one toolkit to build collaborative products like Figma, Notion, and more.

25 lines (22 loc) 621 B
import { isApple } from './is-apple.js'; const MODIFIERS = { alt: () => "altKey", ctrl: () => "ctrlKey", meta: () => "metaKey", mod: () => isApple() ? "metaKey" : "ctrlKey", shift: () => "shiftKey" }; function isKey(event, key, modifiers = {}) { if (event.key !== key) { return false; } const explicitModifiers = Object.entries(modifiers).filter( ([, value]) => typeof value === "boolean" ); return explicitModifiers.every(([modifier, value]) => { const property = MODIFIERS[modifier](); return event[property] === value; }); } export { isKey }; //# sourceMappingURL=is-key.js.map