const Keyboard = window.SimpleKeyboard.default; const keyboard = new Keyboard({ onChange: input => onChange(input), onKeyPress: button => onKeyPress(button) }); /** * Update simple-keyboard when input is changed directly */ document.querySelector(".input").addEventListener("input", event => { keyboard.setInput(event.target.value); }); console.log(keyboard); function onChange(input) { document.querySelector(".input").value = input; console.log("Input changed", input); } function onKeyPress(button) { console.log("Button pressed", button); /** * If you want to handle the shift and caps lock buttons */ if (button === "{shift}" || button === "{lock}") handleShift(); } function handleShift() { const currentLayout = keyboard.options.layoutName; const shiftToggle = currentLayout === "default" ? "shift" : "default"; keyboard.setOptions({ layoutName: shiftToggle }); }