Hex Core JS
    Preparing search index...

    Function onEnterKeyPress

    • Wraps the given function in an event handler function that only calls the given function if the Enter/Return key is pressed.

      Useful with the onKeyDown HTML prop for onClick-like behavior.

      Type Parameters

      • T extends HTMLElement = HTMLElement

      Parameters

      • fn: (event: KeyboardEvent<T>) => void

        The function to call when the Enter/Return key is pressed.

      Returns (event: KeyboardEvent<T>) => void