Provide OS keyboard layout functionality as a nodejs module
Перейти к файлу
Alex Dima a66d880361
2.5.0
2021-10-25 16:26:05 +02:00
.vscode update to tasks 2.0.0 2021-07-06 15:12:56 +02:00
deps/chromium support XK_ISO_Level3_Shift and XK_ISO_Level5_Shift 2020-05-24 07:53:17 +02:00
src Revert "Add support for detecting keyboard layout changes on X11 (microsoft/vscode#23690)" 2021-10-25 16:24:38 +02:00
test support XK_ISO_Level3_Shift and XK_ISO_Level5_Shift 2020-05-24 07:53:17 +02:00
.gitignore Add onDidChangeKeyboardLayout on Mac 2017-03-21 18:55:09 +01:00
.npmignore More build script tweaks 2019-07-04 23:26:02 +02:00
License.txt Add Copyright headers 2015-12-04 10:45:44 +01:00
README.md Adds SUSE-based Linux install instructions 2020-09-12 17:23:46 +02:00
SECURITY.md Add SECURITY.md 2021-03-10 15:00:42 +01:00
ThirdPartyNotices.txt Add ThirdPartyNotices.txt 2015-12-04 10:45:45 +01:00
azure-pipelines.yml Revert "chore: cleanup instance data" 2021-10-25 16:24:26 +02:00
binding.gyp AIX compilation 2021-09-29 11:34:46 +02:00
build-template.yml Revert "chore: cleanup instance data" 2021-10-25 16:24:26 +02:00
index.d.ts Respect current effective group index when getting key map (microsoft/vscode#24166) 2021-10-12 23:25:08 +02:00
index.js Add isISOKeyboard() 2017-04-28 15:33:16 +02:00
package-lock.json 2.5.0 2021-10-25 16:26:05 +02:00
package.json 2.5.0 2021-10-25 16:26:05 +02:00

README.md

OS key mapping node module Build Status

Returns what characters are produced by pressing keys with different modifiers on the current system keyboard layout.

Installing

  • On Debian-based Linux: sudo apt-get install libx11-dev libxkbfile-dev
  • On Red Hat-based Linux: sudo yum install libx11-devel.x86_64 libxkbfile-devel.x86_64 # or .i686
  • On SUSE-based Linux: sudo zypper install libX11-devel libxkbfile-devel
  • On FreeBSD: sudo pkg install libX11
npm install native-keymap

Using

var keymap = require('native-keymap');
console.log(keymap.getKeyMap());

Example output when using standard US keyboard layout (on Windows):

[
  ...
  Space:        { vkey: 'VK_SPACE',      value: ' ',  withShift: ' ', withAltGr: '', withShiftAltGr: '' },
  Minus:        { vkey: 'VK_OEM_MINUS',  value: '-',  withShift: '_', withAltGr: '', withShiftAltGr: '' },
  Equal:        { vkey: 'VK_OEM_PLUS',   value: '=',  withShift: '+', withAltGr: '', withShiftAltGr: '' },
  BracketLeft:  { vkey: 'VK_OEM_4',      value: '[',  withShift: '{', withAltGr: '', withShiftAltGr: '' },
  BracketRight: { vkey: 'VK_OEM_6',      value: ']',  withShift: '}', withAltGr: '', withShiftAltGr: '' },
  Backslash:    { vkey: 'VK_OEM_5',      value: '\\', withShift: '|', withAltGr: '', withShiftAltGr: '' },
  Semicolon:    { vkey: 'VK_OEM_1',      value: ';',  withShift: ':', withAltGr: '', withShiftAltGr: '' },
  Quote:        { vkey: 'VK_OEM_7',      value: '\'', withShift: '"', withAltGr: '', withShiftAltGr: '' },
  Backquote:    { vkey: 'VK_OEM_3',      value: '`',  withShift: '~', withAltGr: '', withShiftAltGr: '' },
  Comma:        { vkey: 'VK_OEM_COMMA',  value: ',',  withShift: '<', withAltGr: '', withShiftAltGr: '' },
  Period:       { vkey: 'VK_OEM_PERIOD', value: '.',  withShift: '>', withAltGr: '', withShiftAltGr: '' },
  Slash:        { vkey: 'VK_OEM_2',      value: '/',  withShift: '?', withAltGr: '', withShiftAltGr: '' },
  ...
]

Example output when using German (Swiss) keyboard layout (on Windows):

[
  ...
  Space:        { vkey: 'VK_SPACE',      value: ' ',  withShift: ' ', withAltGr: '',  withShiftAltGr: '' },
  Minus:        { vkey: 'VK_OEM_4',      value: '\'', withShift: '?', withAltGr: '´', withShiftAltGr: '' },
  Equal:        { vkey: 'VK_OEM_6',      value: '^',  withShift: '`', withAltGr: '~', withShiftAltGr: '' },
  BracketLeft:  { vkey: 'VK_OEM_1',      value: 'ü',  withShift: 'è', withAltGr: '[', withShiftAltGr: '' },
  BracketRight: { vkey: 'VK_OEM_3',      value: '¨',  withShift: '!', withAltGr: ']', withShiftAltGr: '' },
  Backslash:    { vkey: 'VK_OEM_8',      value: '$',  withShift: '£', withAltGr: '}', withShiftAltGr: '' },
  Semicolon:    { vkey: 'VK_OEM_7',      value: 'ö',  withShift: 'é', withAltGr: '',  withShiftAltGr: '' },
  Quote:        { vkey: 'VK_OEM_5',      value: 'ä',  withShift: 'à', withAltGr: '{', withShiftAltGr: '' },
  Backquote:    { vkey: 'VK_OEM_2',      value: '§',  withShift: '°', withAltGr: '',  withShiftAltGr: '' },
  Comma:        { vkey: 'VK_OEM_COMMA',  value: ',',  withShift: ';', withAltGr: '',  withShiftAltGr: '' },
  Period:       { vkey: 'VK_OEM_PERIOD', value: '.',  withShift: ':', withAltGr: '',  withShiftAltGr: '' },
  Slash:        { vkey: 'VK_OEM_MINUS',  value: '-',  withShift: '_', withAltGr: '',  withShiftAltGr: '' },
  ...
]

Supported OSes

  • linux (X11)
  • windows
  • mac
  • freebsd

Known issues

  • only tested from the Electron Main process

Developing

  • npm install -g node-gyp
  • node-gyp configure (for debugging use node-gyp configure -d)
  • node-gyp build
  • npm test (for debugging change index.js to load the node module from the Debug folder and press F5)

License

MIT