import { Arr, Fun } from '@ephox/katamari'; import type { EventArgs } from '@ephox/sugar'; export type KeyMatcher = (evt: EventArgs) => boolean; const inSet = (keys: ReadonlyArray): KeyMatcher => (event: EventArgs) => { const raw = event.raw; return Arr.contains(keys, raw.which); }; const and = (preds: KeyMatcher[]): KeyMatcher => (event: EventArgs) => Arr.forall(preds, (pred) => pred(event)); const is = (key: number): KeyMatcher => (event: EventArgs) => { const raw = event.raw; return raw.which === key; }; const isShift = (event: EventArgs): boolean => { const raw = event.raw; return raw.shiftKey === true; }; const isControl = (event: EventArgs): boolean => { const raw = event.raw; return raw.ctrlKey === true; }; const isNotControl: (event: EventArgs) => boolean = Fun.not(isControl); const isNotShift: (event: EventArgs) => boolean = Fun.not(isShift); export { inSet, and, is, isShift, isNotShift, isControl, isNotControl };