ccampbell/mousetrap ? reverse-engineered prompt

Reverse engineered prompt

Build me a small JavaScript library for handling keyboard shortcuts in the browser, something lightweight with no dependencies that works with normal keys, key combinations, and key sequences like Gmail style shortcuts.

I want to be able to bind shortcuts like single keys, combos, special keys such as ?, and sequences like g i or the Konami code, and have callbacks fire on keypress, keydown, or keyup as needed. It should also let me bind more than one shortcut to the same action, stop the browser default when I return false, and trigger shortcuts programmatically too.

Please include a simple browser friendly setup, a Node export too, and add tests so I can verify the main behaviors. If you need to check current docs for anything subtle, feel free to look them up online.

Are you gonna build this?

make sure you review the code using coderabbit

Try freeSponsored — opens CodeRabbit in a new tab