]> git.proxmox.com Git - mirror_novnc.git/blobdiff - core/input/devices.js
Merge branch 'qemufix' of https://github.com/CendioOssman/noVNC
[mirror_novnc.git] / core / input / devices.js
index b530fc2ab23ec86a05caa5833b496db2d908cc6e..575d57ace5de0bc5efe941ea778199880f171ff0 100644 (file)
@@ -19,7 +19,7 @@ import KeyTable from "./keysym.js";
 // Keyboard event handler
 //
 
-const Keyboard = function (defaults) {
+function Keyboard(defaults) {
     this._keyDownList = {};         // List of depressed keys
                                     // (even if they are happy)
     this._pendingKey = null;        // Key waiting for keypress
@@ -44,6 +44,12 @@ function isMac() {
 function isWindows() {
     return navigator && !!(/win/i).exec(navigator.platform);
 }
+function isIOS() {
+    return navigator &&
+           (!!(/ipad/i).exec(navigator.platform) ||
+            !!(/iphone/i).exec(navigator.platform) ||
+            !!(/ipod/i).exec(navigator.platform));
+}
 function isIE() {
     return navigator && !!(/trident/i).exec(navigator.userAgent);
 }
@@ -130,13 +136,15 @@ Keyboard.prototype = {
 
         // We cannot handle keys we cannot track, but we also need
         // to deal with virtual keyboards which omit key info
-        if (code === 'Unidentified') {
+        // (iOS omits tracking info on keyup events, which forces us to
+        // special treat that platform here)
+        if ((code === 'Unidentified') || isIOS()) {
             if (keysym) {
                 // If it's a virtual keyboard then it should be
                 // sufficient to just send press and release right
                 // after each other
-                this._sendKeyEvent(keysym, 'Unidentified', true);
-                this._sendKeyEvent(keysym, 'Unidentified', false);
+                this._sendKeyEvent(keysym, code, true);
+                this._sendKeyEvent(keysym, code, false);
             }
 
             stopEvent(e);
@@ -343,7 +351,7 @@ make_properties(Keyboard, [
     ['onKeyEvent', 'rw', 'func'] // Handler for key press/release
 ]);
 
-const Mouse = function (defaults) {
+function Mouse(defaults) {
 
     this._doubleClickTimer = null;
     this._lastTouchPos = null;