export function getCommandFromEvent()

in packages/roosterjs-react-command-bar/lib/plugins/RoosterCommandBarPlugin.Shortcuts.ts [176:196]


export function getCommandFromEvent(event: PluginEvent): RoosterShortcutCommands {
    if (event.eventType !== PluginEventType.KeyDown) {
        return RoosterShortcutCommands.None;
    }

    const commands = Browser.isMac ? macCommands : winCommands;
    const keyboardEvent = (event as PluginDomEvent).rawEvent as KeyboardEvent;
    for (const cmd of commands) {
        if (
            !keyboardEvent.altKey &&
            cmd.ctrlKey === keyboardEvent.ctrlKey &&
            cmd.metaKey === keyboardEvent.metaKey &&
            cmd.shiftKey === keyboardEvent.shiftKey &&
            cmd.which === keyboardEvent.which
        ) {
            return cmd.command;
        }
    }

    return RoosterShortcutCommands.None;
}