-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make it easy to bind to "?" #5
Comments
I've been thinking about special keys like |
How about at least providing a couple of hooks so that users who want to do special key handling can? |
Sure, that's easy enough. I'll likely add hooks the next release. See issue #7 |
I'll take a look at the hooks issue. You'll notice that when I raise the same issue on Keymaster, it went nowhere. This is not an easy thing to solve while keeping a low API profile. |
Yea I saw you grabbed my Hooks branch. Is that kind of what your looking for? |
Are you still looking for this @jamesarosen ? |
I'm definitely interested, but I haven't had a chance to investigate it myself. |
Are you essentially looking for a way to bind a hook that lets you modify the active keys and combos arrays? Or are you looking for a way to modify the event object passed to event handlers? |
Ideally: // This knows that `?` can't be bound with keydown and keyup,
// but must use keypress.
KeyboardJS.bind.key('?', function() { ... }); Just fine: KeyboardJS.bind.keypress('?', function() { ... }); Also totally acceptable, though this seems like extra setup work that many people would have to do: KeyboardJS.bind.parseEvents = function(combo, onKeyDown, onKeyUp) {
if (combo === '?') { return { keypress: onKeyDown }; }
return { keydown: onKeyDown, keyup: onKeyUp };
};
...
KeyboardJS.bind.key('?', function() { ... }); |
Ah... Ok I'm on it. |
Fixed in v0.3.0. You can bind to ? off the bat with
Note that '?' is already part of the US locale out of the box, but if it wasn't, the above would add it. Once a macro is added you can use it in you key combos like any other key name. |
I assume a lot has changed since 2012. I'm trying to get "?" working with a German keyboard layout This does not get me anywhere, neither "ß" nor "shift + ß" work. keyboardJS._locale.bindKeyCode(223, ['ß']);
keyboardJS._locale.bindMacro('shift + ß', ['?']);
keyboardJS.bind('ß', console.log.bind(console, 'ß'));
keyboardJS.bind('shift + ?', console.log.bind(console, 'shift + ?'));
keyboardJS.bind('?', console.log.bind(console, '?')); Source: https://en.wikipedia.org/wiki/German_keyboard_layout |
@Prinzhorn In case you're still interested or for anyone else who stumbles upon this, the code snippet above did not work, because the Note, however, that there is a bug in the current keyboardJS version (see #164) which affects shortcuts using secondary key symbols (as |
@daniel-wer I'm currently not using KeyboardJS in any project, but I might be in the future. Thanks for looking into this! How did you come up with 219? See screenshot, this is me hitting the "ß" key on this very GitHub page. |
Unfortunately, keyboard events are a mess and the keyCode is different between keydown/keyup and keypress events, because they are different types of events. There is hope, though, in the form of UI events which should make all of this easier to work with. If you use |
The only way to bind to
?
currently is to bind to "shift-slash," which only works on some keyboards. The trouble is that the only way to do a real binding to?
is to useonKeyPress
, instead ofonKeyUp
, which doesn't work in other cases. This is a known problem area for nearly all keybinding libraries. I'd love to hear your thoughts on how to do this elegantly.The text was updated successfully, but these errors were encountered: