Ascii code generation for the combination of keys
-
10-10-2019 - |
Pergunta
i want to know how to get the ascii code for the combination of keys. Like i want to handle event for some unique key combination [alt+ctrl+shift]. Alternatively can you please tell me the ascii code for [alt+Enter], [ctrl+Enter].
Solução
There are flags on the event
object that tell you if the alt, control or shift keys have been entered:
if (event.shiftKey) {}
if (event.altKey) {}
if (event.ctrlKey) {}
To get the key code (e.g. space), you need to check the event.keycode
(13 will get you enter)
if (event.keyCode === 13){}
Outras dicas
There aren't really standard mappings from keyboard codes to ASCII. Maybe this PC keyboard scan code table will help.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow