werkbank
    Preparing search index...

    Function useOnEscape

    • Triggers a callback when the Escape key is pressed.

      Parameters

      • fn: (e: KeyboardEvent) => void

        The function to call when Escape is pressed.

      Returns void

      This hook subscribes to the global keyup$ observable and filters for the "Escape" key. Useful for closing modals, tooltips, or cancelling actions.

      useOnEscape(() => {
      setIsOpen(false);
      });