tickle/modules/onDocumentKey.mjs

12 lines
233 B
JavaScript
Raw Normal View History

/**
*
* @param {string} keyToListen
* @param {()=>void} callback
*/
export const onDocumentKeyUp = (keyToListen, callback) => {
document.addEventListener(
"keyup",
({ key }) => key === keyToListen && callback()
);
};