import React from 'react';
import { K as KEY_CODES } from './key_codes-ff72266d.js';

function useEnterKey(onEnter) {
  var ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
    current: document
  };
  var handleKeyUp = React.useCallback(function (e) {
    if (e.keyCode === KEY_CODES.ENTER) {
      onEnter(e);
    }
  }, [onEnter]);
  React.useEffect(function () {
    ref.current && ref.current.addEventListener("keyup", handleKeyUp);
    return function () {
      return ref.current.removeEventListener("keyup", handleKeyUp);
    };
  }, [handleKeyUp]);
}

export { useEnterKey as u };
