github / hotkey

Trigger an action on an element with a keyboard shortcut.
https://github.github.com/hotkey/
MIT License
3.22k stars 97 forks source link

Handle keypresses in elements with dotted ids #58

Closed Aarononomous closed 2 years ago

Aarononomous commented 2 years ago

I'm throwing errors every time I keydown in an element with a dotted id. For example, <div id="account.firm">.

I think this should be resolvable by quoting and escaping the target id in the querySelector, index.ts line 23, from

if (!target.ownerDocument.querySelector(`[data-hotkey-scope=${target.id}]`)) return

to

if (!target.ownerDocument.querySelector(`[data-hotkey-scope="${CSS.escape(target.id)}"]`)) return
keithamus commented 2 years ago

Thanks for the report @Aarononomous! It's fixed in 1.6.1 :tada: