简体   繁体   中英

how to handle non english key presses

When I switch my keyboard layout to hebrew and press a character, it is received in the kepress event as is. For example, clicking ה (the v key), then e.which is 1492. However, when I do a combination the key is the english key. So for alt+ה e.which is 86. So the event looks like alt+v

This is a pain if I want to create a function that accepts key combinations and callbacks and registers the callbacks but also shows a documentation of the callbacks, since if I register alt+ה , then when I press the combination it will look like alt+v and it wouldn't match the registered combinations. But if I register alt+v , then the documentation will be awkward.

So my question boils down to whether one of the following is possible:

  1. knowing which key actually was pressed (meaning, knowing that ה was pressed together with alt and not v )
  2. mapping between the hebrew characters (or any non-english) to their physical english counterparts, so when my function receives alt+ה it will convert it to alt+v for the callback lookup.

Of course I want something generic, that will work for any language, not list just the hebrew alphabet.

  1. You should not care if it is alt-ה or alt-v, you want to perform the same operation on both cases.
  2. If it is not identified, it is not identified anywhere, so your function will get alt-v as well.
  3. if your function gets something ("Alt", "ה") you should create an object for conversion. var conv= { 'ה': 'v'; 'ש': 'a',...}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM