event.keyCode alternative

后端 未结 1 1360
无人共我
无人共我 2021-01-18 23:03

I am developing a virtual keyboard extension for Firefox. One of the features of this extension is converting the keys the user presses to another layout.

Example: I

相关标签:
1条回答
  • 2021-01-18 23:34

    The available properties for KeyboardEvents are described on the linked page on MDN. They include:

    • KeyboardEvent.altKey
    • KeyboardEvent.charCode (Deprecated)
    • KeyboardEvent.code
    • KeyboardEvent.ctrlKey
    • KeyboardEvent.isComposing
    • KeyboardEvent.key
    • KeyboardEvent.keyCode (Deprecated)
    • KeyboardEvent.location
    • KeyboardEvent.metaKey
    • KeyboardEvent.shiftKey
    • KeyboardEvent.which (Deprecated)

    KeyboardEvent.code appears to be the one which may provide you with the best information, and is not deprecated. However, it is only available from Firefox 32.0 in the Nightly, Aurora and Developer Editions of Firefox. From Firefox 38.0 and onwards it is, or will be, available in the standard release version.

    You may have to experiment with various combinations of charCode, code, key, keyCode, and which to get the information you desire. If you desire to support a wide range of Firefox releases, you will almost certainly have to use a combination of different properties.

    0 讨论(0)
提交回复
热议问题