Function onKey

  • This returns a function which will stop an event handler run (typically for keyup, keydown etc) from continuing if it has not been triggered by the specified key. The returned functions are to be placed before the main handler functions in the ops array passed to eventListener.

    Parameters

    • key: string

    Returns ((e) => "" | typeof END)

      • (e): "" | typeof END
      • Parameters

        • e: KeyboardEvent

        Returns "" | typeof END

    Example

    import { eventListener, onKey } from 'deleight/eutility';
    const aKeyGuard = onKey('a');
    window.firstInput.keyup = eventListener([aKeyGuard, (e, runContext) => {
    // handle event here.
    }]);