Restore handling of key events for virtual keyboard
We broke handling of keydown/keyup when we moved the focus to the canvas, as events from our input element would then no longer be caught when they bubbled up to the document object (where we previously caught events). Restore the previous behaviour in a cleaner manner by creating a second Keyboard object to handle this extra input variant.
This commit is contained in:
parent
06fe4a3e1b
commit
867daa98af
10
app/ui.js
10
app/ui.js
|
@ -17,6 +17,7 @@ import { isTouchDevice, browserSupportsCursorURIs as cursorURIsSupported } from
|
||||||
import { setCapture, getPointerEvent } from '../core/util/events.js';
|
import { setCapture, getPointerEvent } from '../core/util/events.js';
|
||||||
import KeyTable from "../core/input/keysym.js";
|
import KeyTable from "../core/input/keysym.js";
|
||||||
import keysyms from "../core/input/keysymdef.js";
|
import keysyms from "../core/input/keysymdef.js";
|
||||||
|
import Keyboard from "../core/input/keyboard.js";
|
||||||
import RFB from "../core/rfb.js";
|
import RFB from "../core/rfb.js";
|
||||||
import Display from "../core/display.js";
|
import Display from "../core/display.js";
|
||||||
import * as WebUtil from "./webutil.js";
|
import * as WebUtil from "./webutil.js";
|
||||||
|
@ -280,6 +281,9 @@ var UI = {
|
||||||
document.getElementById("noVNC_keyboard_button")
|
document.getElementById("noVNC_keyboard_button")
|
||||||
.addEventListener('click', UI.toggleVirtualKeyboard);
|
.addEventListener('click', UI.toggleVirtualKeyboard);
|
||||||
|
|
||||||
|
UI.touchKeyboard = new Keyboard({target: document.getElementById('noVNC_keyboardinput'),
|
||||||
|
onKeyEvent: UI.keyEvent});
|
||||||
|
UI.touchKeyboard.grab();
|
||||||
document.getElementById("noVNC_keyboardinput")
|
document.getElementById("noVNC_keyboardinput")
|
||||||
.addEventListener('input', UI.keyInput);
|
.addEventListener('input', UI.keyInput);
|
||||||
document.getElementById("noVNC_keyboardinput")
|
document.getElementById("noVNC_keyboardinput")
|
||||||
|
@ -1506,6 +1510,12 @@ var UI = {
|
||||||
UI.lastKeyboardinput = kbi.value;
|
UI.lastKeyboardinput = kbi.value;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
keyEvent: function (keysym, code, down) {
|
||||||
|
if (!UI.rfb) return;
|
||||||
|
|
||||||
|
UI.rfb.sendKey(keysym, code, down);
|
||||||
|
},
|
||||||
|
|
||||||
// When normal keyboard events are left uncought, use the input events from
|
// When normal keyboard events are left uncought, use the input events from
|
||||||
// the keyboardinput element instead and generate the corresponding key events.
|
// the keyboardinput element instead and generate the corresponding key events.
|
||||||
// This code is required since some browsers on Android are inconsistent in
|
// This code is required since some browsers on Android are inconsistent in
|
||||||
|
|
Loading…
Reference in New Issue