Provide OS keyboard layout functionality as a nodejs module
Перейти к файлу
Robo d0f4fb507b
fix: opt-out for nogc finalizer change (#59)
* fix: opt-out for nogc finalizer change

* chore: bump 3.3.5
2024-04-16 15:51:40 +00:00
.github/workflows Fix CI (#56) 2024-01-22 14:25:49 +01:00
.vscode add pipeline 2022-11-21 16:42:43 +01:00
deps/chromium Update to latest `keysym_to_unicode` 2022-01-13 12:45:26 +01:00
src fix: opt-out for nogc finalizer change (#59) 2024-04-16 15:51:40 +00:00
test CRLF -> LF 2022-02-04 14:15:11 +01:00
.git-blame-ignore Add `.git-blame-ignore` file 2022-02-14 18:08:05 +01:00
.gitattributes CRLF -> LF 2022-02-04 14:15:11 +01:00
.gitignore Add onDidChangeKeyboardLayout on Mac 2017-03-21 18:55:09 +01:00
.npmignore improve .npmignore (#47) 2022-11-22 17:10:08 +01:00
License.txt Add Copyright headers 2015-12-04 10:45:44 +01:00
PoliCheckExclusions.xml Exclude the chromium source code from PoliCheck (#55) 2024-01-22 07:51:27 -08: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 CRLF -> LF 2022-02-04 14:15:11 +01:00
binding.gyp chore: skip reporting C4244 as error (#52) 2023-04-24 07:41:40 +02:00
index.d.ts CRLF -> LF 2022-02-04 14:15:11 +01:00
index.js Fallback to using the debug build (#42) 2022-08-04 11:50:17 +02:00
package-lock.json fix: opt-out for nogc finalizer change (#59) 2024-04-16 15:51:40 +00:00
package.json fix: opt-out for nogc finalizer change (#59) 2024-04-16 15:51:40 +00:00
pipeline.yml fix: opt-out for nogc finalizer change (#59) 2024-04-16 15:51:40 +00: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