/** @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/location */
export var KeyLocation;
(function (KeyLocation) {
    KeyLocation[KeyLocation["Standard"] = 0] = "Standard";
    KeyLocation[KeyLocation["Left"] = 1] = "Left";
    KeyLocation[KeyLocation["Right"] = 2] = "Right";
    KeyLocation[KeyLocation["Numpad"] = 3] = "Numpad";
})(KeyLocation || (KeyLocation = {}));
export function isMatch(trigger, event) {
    if (('ctrl' in trigger && trigger.ctrl !== event.ctrlKey) ||
        ('shift' in trigger && trigger.shift !== event.shiftKey) ||
        ('alt' in trigger && trigger.alt !== event.altKey) ||
        ('meta' in trigger && trigger.meta !== event.metaKey))
        return false;
    return 'key' in trigger
        ? 'key' in event && event.key === trigger.key && (!('location' in trigger) || trigger.location === event.location)
        : 'button' in event && event.button === trigger.button;
}
export function find(triggers, event) {
    for (const trigger of triggers) {
        if (isMatch(trigger, event))
            return trigger;
    }
}
