How to use the native-keymap.getKeyMap function in native-keymap

To help you get started, we’ve selected a few native-keymap examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipse-theia / theia / packages / core / scripts / generate-layout.js View on Github external
*           Display name of the keyboard layout (without dashes)
 *       `pc` or `mac`
 */
const args = parseArgs(process.argv);
const printInfo = args['info'];
const includeAll = args['all'];
const prettyPrint = args['pretty'];
const outFile = args['output'];

let output;
if (printInfo) {
    output = nativeKeymap.getCurrentKeyboardLayout();
} else {
    output = {
        info: nativeKeymap.getCurrentKeyboardLayout(),
        mapping: nativeKeymap.getKeyMap()
    };
    if (!includeAll) {
        // We store only key codes for the "writing system keys" as defined here:
        // https://w3c.github.io/uievents-code/#writing-system-keys
        const ACCEPTED_CODES = [
            'KeyA', 'KeyB', 'KeyC', 'KeyD', 'KeyE', 'KeyF', 'KeyG', 'KeyH', 'KeyI', 'KeyJ', 'KeyK', 'KeyL', 'KeyM',
            'KeyN', 'KeyO', 'KeyP', 'KeyQ', 'KeyR', 'KeyS', 'KeyT', 'KeyU', 'KeyV', 'KeyW', 'KeyX', 'KeyY', 'KeyZ',
            'Digit1', 'Digit2', 'Digit3', 'Digit4', 'Digit5', 'Digit6', 'Digit7', 'Digit8', 'Digit9', 'Digit0',
            'Minus', 'Equal', 'BracketLeft', 'BracketRight', 'Backslash', 'Semicolon', 'Quote', 'Backquote',
            'Comma', 'Period', 'Slash', 'IntlBackslash', 'IntlRo', 'IntlYen'
        ];
        const ACCEPTED_VARIANTS = ['value', 'withShift', 'withAltGr', 'withShiftAltGr', 'vkey'];
        for (let code of Object.keys(output.mapping)) {
            if (ACCEPTED_CODES.indexOf(code) < 0) {
                delete output.mapping[code];
            } else {
github eclipse-theia / theia / packages / core / src / electron-node / keyboard / electron-keyboard-layout-provider.ts View on Github external
protected getNativeLayoutSync(): NativeKeyboardLayout {
        return {
            info: nativeKeymap.getCurrentKeyboardLayout(),
            mapping: nativeKeymap.getKeyMap()
        };
    }

native-keymap

Get OS key mapping

MIT
Latest version published 20 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages