3 ms·
> But wait, can't you like, define some reasonable presets and let people > choose their own? The answer is no, because you don't have a reliable way to > trans
by ville 13y ago
> But wait, can't you like, define some reasonable presets and let people
> choose their own? The answer is no, because you don't have a reliable way to
> translate a keydown/keyup to a unicode char, and the unicode char is related
> to the modifier keys, not the key cap, so though you can do that shortcut
> definition, you can't show to the user what that shortcut definition actually
> is, because it'd be either undefined or completely wrong.
But couldn't you let the user write the shortcut in a text field,
capture the keycodes from the keydown/keyup events and the char from the text field?
Edit: This obviously doesn't work for shortcuts that do not produce any text, such as F-keys. But couldn't you at least get normal keys right most of the time?
- Groxx 13y agoThat's kind of what I was thinking. Add to that a 20-questions thing to check which keyboard layout they're using, and you can probably uniquely detect almost every keyboard layout (minus custom, of course) in a couple keypresses. But if you're going this far, you're probably significantly better off just letting people remap their shortcuts if it doesn't match what 95% of your users are using. The ones that care will love you for it, the ones that don't probably wouldn't have used it or been interested in 20-questions anyway.