ccampbell / mousetrap

Simple library for handling keyboard shortcuts in Javascript
https://craig.is/killing/mice
Apache License 2.0
11.64k stars 966 forks source link

[FAQ] Comparison with KeyboardJS #78

Closed dandv closed 11 years ago

dandv commented 11 years ago

I'm trying to decide which keyboard library to use for a CRM/Project Management open source project to be built with MeteorJS.

Since mousetrap was started about 8 months after KeyboardJS was started, it would help to describe somewhere (README or in the wiki) how mousetrap differs from prior art.

Thanks!

ccampbell commented 11 years ago

I already have a little blurb in the readme https://github.com/ccampbell/mousetrap#why-mousetrap. I'm not familiar with KeyboardJS, so I am not sure about specifics, but one thing I see of the bat is that KeyboardJS minified and gzipped is around 3.89kb whereas mousetrap is around 1.7kb.

Also it looks like it uses keydown and keyup events rather than keypress which means that they will not work reliably across international keyboards.

I'm also not sure if it supports key sequences such as

// press g key followed by h key
Mousetrap.bind('g h', _goHome);

If it does use sequences it doesn't look like they timeout whereas in mousetrap if you don't press the next key within 1 second it resets.

I would try out both libraries and see which one works better for you!