You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
558 B

import { onMounted, onBeforeUnmount } from 'vue';
import { on, off } from '../../utils/dom.mjs';
import { EVENT_CODE } from '../../utils/aria.mjs';
const useEscapeKeydown = (handler) => {
const cachedHandler = (e) => {
const event = e;
if (event.key === EVENT_CODE.esc) {
handler == null ? void 0 : handler(event);
}
};
onMounted(() => {
on(document, "keydown", cachedHandler);
});
onBeforeUnmount(() => {
off(document, "keydown", cachedHandler);
});
};
export { useEscapeKeydown };
//# sourceMappingURL=index.mjs.map