package.dist.index.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of react-use-escape-keydown Show documentation
Show all versions of react-use-escape-keydown Show documentation
radix-ui react-use-escape-keydown
The newest version!
var $b0gz3$react = require("react");
var $b0gz3$radixuireactusecallbackref = require("@radix-ui/react-use-callback-ref");
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
$parcel$export(module.exports, "useEscapeKeydown", () => $24c84e9f83c4454f$export$3a72a57244d6e765);
/**
* Listens for when the escape key is down
*/ function $24c84e9f83c4454f$export$3a72a57244d6e765(onEscapeKeyDownProp, ownerDocument = globalThis === null || globalThis === void 0 ? void 0 : globalThis.document) {
const onEscapeKeyDown = $b0gz3$radixuireactusecallbackref.useCallbackRef(onEscapeKeyDownProp);
$b0gz3$react.useEffect(()=>{
const handleKeyDown = (event)=>{
if (event.key === 'Escape') onEscapeKeyDown(event);
};
ownerDocument.addEventListener('keydown', handleKeyDown);
return ()=>ownerDocument.removeEventListener('keydown', handleKeyDown)
;
}, [
onEscapeKeyDown,
ownerDocument
]);
}
//# sourceMappingURL=index.js.map