Manage Windows On-Screen Keyboard from your Electron app.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore Initial commit Jul 19, 2017
.npmignore Initial commit Jul 19, 2017
README.md Add Windows compatibility note Jul 20, 2017
binding.gyp Initial commit Jul 19, 2017
dev.js Initial commit Jul 19, 2017
export.js Quick README Jul 20, 2017
main.cpp Initial commit Jul 19, 2017
package.json Node 10 compatibility Sep 28, 2018

README.md

Electron Windows OSK

Windows on-screen keyboard manager for Electron apps.

This experimental package allows you to show, close, resize and position the built in on-screen Windows keyboard. Take a look at export.js to check out the API.

This should work in Win 7 and up.

Short example:

import WindowsOSK from 'electron-windows-osk';
const OSK = new WindowsOSK(browserWindowInstance);

// Open and position OSK on click in inputs.
document.addEventListener('click', (event) => {
    if (event.target.tagName === 'INPUT' && event.target.tagName === 'TEXTAREA') {
        const viewportOffset = event.target.getBoundingClientRect();
        const inBrowserYOffset =
            (
                viewportOffset.top - // Element top offset.
                window.scrollY       // If the page is scrolled we need to substract the scroll y.
            );

        OSK.showFromEvent(inBrowserYOffset, event.target.clientHeight, 5);
        // meteor-desktop: Desktop.send('virtualKeyboard', 'show', inBrowserYOffset, event.target.clientHeight, 5);
    }
});

// Close the OSK on any other click.
document.addEventListener('click', (event) => {
    if (event.target.tagName !== 'INPUT' && event.target.tagName !== 'TEXTAREA') {
        OSK.close();
        // meteor-desktop: Desktop.send('virtualKeyboard', 'close');
    }
});

Example of meteor-desktop module:

import WindowsOSK from 'electron-windows-osk';

export default class VirtualKeyboardModule {
    constructor({ log, eventsBus, Module }) {
        this.log = log;
        let virtualKeyboardModule = new Module('virtualKeyboard');

        eventsBus.on('windowCreated', (window) => {
            this.window = window;
            console.log(WindowsOSK);
            this.windowsOSK = new WindowsOSK(window);
        });

        virtualKeyboardModule.on('show', this.showKeyboard.bind(this));
        virtualKeyboardModule.on('close', this.closeKeyboard.bind(this));

        this.windowsOSK = null;
    }

    showKeyboard(event, inBrowserYOffset, height, padding) {
        this.windowsOSK.showFromEvent(inBrowserYOffset, height, padding);
    }

    closeKeyboard() {
        this.windowsOSK.close();
    }
};