keithamus / jwerty

⌨ Awesome handling of keyboard events
http://keithamus.github.io/jwerty
Other
1.21k stars 107 forks source link

Enable distinguishing of casing #25

Open creage opened 12 years ago

creage commented 12 years ago

Well, imagine you have a binding like "Q", and "q" - both of them are fired by hitting "Q" key on your keyboard.

But if you somehow display these keys on the screen of your app - users type shift+q to match the uppercase "Q", and just q for lowercase "q".

Hence, it would be nice if jwerty could detect shift+key, if bound key IS IN uppercase.

keithamus commented 12 years ago

There are lots of edge-cases to this that would require looking at. It would be a nice to have but not a priority, unless you want to submit a PR?

creage commented 12 years ago

Currently I see that jwerty is explicitly lowercases all of codes. What if we just leave all of codes as users bind them?

keithamus commented 12 years ago

It lowercases codes to make selection of said codes easier. If you jwerty.key("shift+q"... it should fire on those to keys pressed in combination, its a little ambiguious to use jwerty.key("Q"... or jwerty.key("q", as it can be prone to errors or typos (other typos could include jwerty.key("Shift+q"...

Also there is a case where if the caps-lock is on, what key does it fire? Q or q?

creage commented 12 years ago

OK. For now I'm dealing like this

if (key == key.toUpperCase()) { key = key + "/shift+" + key; }