diff --git a/Blink/SceneDelegate.swift b/Blink/SceneDelegate.swift
index 71b6d77e9..7b60264ef 100644
--- a/Blink/SceneDelegate.swift
+++ b/Blink/SceneDelegate.swift
@@ -118,15 +118,17 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate {
debugPrint("BK:", "stuck!!!")
input.setTrackingModifierFlags([])
- let ctrl = UIHostingController(rootView: StuckView(keyCode: key, dismissAction: {
- spCtrl.onStuckOpCommand()
- }))
-
- ctrl.modalPresentationStyle = .formSheet
- spCtrl.stuckKeyCode = key
- spCtrl.present(ctrl, animated: false)
+ if input.isHardwareKB && key == .commandLeft {
+ let ctrl = UIHostingController(rootView: StuckView(keyCode: key, dismissAction: {
+ spCtrl.onStuckOpCommand()
+ }))
+
+ ctrl.modalPresentationStyle = .formSheet
+ spCtrl.stuckKeyCode = key
+ spCtrl.present(ctrl, animated: false)
- return
+ return
+ }
}
spCtrl.stuckKeyCode = nil
diff --git a/Blink/SmarterKeys/SmarterTermInput.swift b/Blink/SmarterKeys/SmarterTermInput.swift
index ee2136236..4f4c112dc 100644
--- a/Blink/SmarterKeys/SmarterTermInput.swift
+++ b/Blink/SmarterKeys/SmarterTermInput.swift
@@ -37,6 +37,8 @@ class SmarterTermInput: KBWebView {
private var _hideSmartKeysWithHKB = !BKUserConfigurationManager.userSettingsValue(forKey: BKUserConfigShowSmartKeysWithXKeyBoard)
private var _inputAccessoryView: UIView? = nil
+ var isHardwareKB: Bool { _kbView.traits.isHKBAttached }
+
var device: TermDevice? = nil {
didSet { reportStateReset() }
}
@@ -125,7 +127,7 @@ class SmarterTermInput: KBWebView {
private func _reportLang() {
let lang = self.textInputMode?.primaryLanguage ?? ""
_kbView.lang = lang
- reportLang(lang)
+ reportLang(lang, isHardwareKB: _kbView.traits.isHKBAttached)
}
override var inputAssistantItem: UITextInputAssistantItem {
@@ -513,6 +515,11 @@ extension SmarterTermInput {
func stuckKey() -> KeyCode? {
let mods: UIKeyModifierFlags = [.shift, .control, .alternate, .command]
let stuck = mods.intersection(trackingModifierFlags)
+
+ // Return command key first
+ if stuck.contains(.command) {
+ return KeyCode.commandLeft
+ }
if stuck.contains(.shift) {
return KeyCode.shiftLeft
@@ -525,10 +532,6 @@ extension SmarterTermInput {
return KeyCode.optionLeft
}
- if stuck.contains(.command) {
- return KeyCode.commandLeft
- }
-
return nil
}
}
diff --git a/KB/JS/dist/kb.js b/KB/JS/dist/kb.js
index 56c6cb650..8c4c017c8 100644
--- a/KB/JS/dist/kb.js
+++ b/KB/JS/dist/kb.js
@@ -1 +1 @@
-!function(e){var t={};function a(o){if(t[o])return t[o].exports;var s=t[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,a),s.l=!0,s.exports}a.m=e,a.c=t,a.d=function(e,t,o){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(a.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)a.d(o,s,function(t){return e[t]}.bind(null,s));return o},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=new(a(1).default);document.body.append(o.element),o.focus(!0),window._onKB=o.onKB,window._kb=o,o.ready()},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=a(2),s=a(3),l=a(4),n=o.KBActions.CANCEL,r=o.KBActions.DEFAULT,i=o.KBActions.PASS,d=o.KBActions.STRIP;function c(e){let t="",a=e.length;for(let o=0;o{let t=e.code;if(this._capsLockRemapped){let a;a="keyup"==e.type&&"CapsLock"==t?0:s.toUIKitFlags(e),o.op("mods",{mods:a})}"AltLeft"!=t&&"AltRight"!=t||this._ignoreAccents[t]&&("keydown"==e.type?o.op("guard-ime-on",{}):o.op("guard-ime-off",{}),f(e))},this._downKeysIds=()=>{let e=Array.from(this._down);return this._mods.Meta.has("tb-meta")&&-1==e.indexOf(k)&&e.push(k),this._mods.Control.has("tb-ctrl")&&-1==e.indexOf(p)&&e.push(p),this._mods.Alt.has("tb-alt")&&-1==e.indexOf(C)&&e.push(C),this._mods.Shift.has("tb-shift")&&-1==e.indexOf(m)&&e.push(m),e},this._onKeyDown=e=>{if(e.isComposing)return void(this._lastKeyDownEvent=null);let t=e;if(229===e.keyCode){if(!this._lastKeyDownEvent)return;t=this._lastKeyDownEvent}else this._lastKeyDownEvent=e;let a=_(t);this._down.add(a);let o=this._bindings.match(this._downKeysIds());if(y.has(a)||this._down.delete(a),o)return this._execBinding(o,e),void f(e);let s=this._downMap[a],l=this._mod(this._modsMap[t.code]),n=!1;s&&((n=!(l&&this._mods[l].has(a)))||(this._handleKeyDownKey(s,e),n=!0)),l&&this._mods[l].add(a),this._upMap[a]&&this._up.add(a),this._updateUIKitModsIfNeeded(t),n||this._handleKeyDown(t.keyCode,e)},this._onBeforeInput=e=>{if("dictation"!==this._lang){if("insertText"===e.inputType&&(this._output(e.data),this._langWithDeletes&&e.data)){this.element.value=e.data;let t=e.data.length;this.element.selectionStart=t,this.element.selectionEnd=t}"deleteContentBackward"===e.inputType&&this._output(o.DEL),f(e)}else o.op("voice",{data:e.data||""})},this._onInput=e=>f(e),this._onKeyUp=e=>{this._lastKeyDownEvent=null;let t=_(e);this._down.delete(t);let a=this._mod(this._modsMap[e.code]);a&&this._mods[a].delete(t),this._updateUIKitModsIfNeeded(e);let o=this._upMap[t];o&&this._up.has(t)&&this._handleKeyDownKey(o,null),f(e)},this._handleKeyDown=(e,t)=>{let a={keyCode:e,key:"",code:"Unidentified"};t&&(a.code=t.code,a.key=t.key),this._handleKeyDownKey(a,t)},this._handleKeyDownKey=(e,t)=>{let a=this._keyMap,s=this._mods.Alt.size>0,l=this._mods.Control.size>0,c=this._mods.Meta.size>0,h=this._mods.Shift.size>0,y=e.code,m=e.key,p=function(e,t,a){if(!a)return e;if(a.ctrlKey){let o=a.key.toLowerCase(),s=a.keyCode;if(8===s&&"h"===o||9===s&&"i"===o||13===s&&"c"===o||13===s&&"m"===o||27===s&&"["===o)return e.keyCode=t.keyCode(o)||e.keyCode,e;let l=a.code;(8===s&&"KeyH"===l||9===s&&"KeyI"===l||13===s&&"KeyC"===l||13===s&&"KeyM"===l||27===s&&"BracketLeft"===l)&&(e.keyCode=t.keyCode(l)||e.keyCode)}return e}({key:m,code:y,keyCode:e.keyCode,alt:s,ctrl:l,meta:c,shift:h},this._keyMap,t),C=a.getKeyDef(p.keyCode);var k=null;function u(e){k=e;var t=C[e];return"function"==typeof t&&(t=t.call(a,p,C)),t===r&&"normal"!==e&&(t=u("normal")),t}let _;if(_=u(l?"ctrl":s?"alt":c?"meta":"normal"),!this._langWithDeletes||"[Backspace]"!==C.keyCap){if(!this.hasSelection&&(_===i||_===r&&!(l||s||c))){if(_===i&&!e.src)return;if(/^\[\w+\]$/.test(C.keyCap)){if(!e.src)return void(this._removeAccents=!1)}else if(this._langWithDeletes)return;let a=this._removeAccents?function(e){let t=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),a=t.replace(/^[\u02c6\u00a8\u00b4\u02dc\u0060]/,"");return a&&(t=a),t}(m):m;return this._removeAccents=!1,this._capsLockRemapped||this._shiftRemapped?this._output(h?a.toUpperCase():a.toLowerCase()):this._output(a),void f(t)}if(this._removeAccents=!1,_===d&&(s=l=!1,"function"==typeof(_=C.normal)&&(_=_.call(a,p,C)),_===r&&2===C.keyCap.length&&(_=C.keyCap.substr(h?1:0,1))),f(t),_!==n&&!this.hasSelection)if(_===r||"string"==typeof _){if("ctrl"===k?l=!1:"alt"===k?s=!1:"meta"===k&&(c=!1),h=p.shift,(s||l||h||c)&&"string"==typeof _&&_.substr(0,2)===o.CSI){let e=1;h&&(e+=1),s&&(e+=2),l&&(e+=4),c&&(e+=8);let t=";"+e;_=3==_.length?o.CSI+"1"+t+_.substr(2,1):_.substr(0,_.length-1)+t+_.substr(_.length-1)}else{if(_===r&&(_=C.keyCap.substr(h?1:0,1),l)){let e=C.keyCap.substr(0,1).charCodeAt(0);e>=64&&e<=95&&(_=String.fromCharCode(e-64))}let e=_.toString();if(s&&"8-bit"==this._altSendsWhat&&1==e.length){let t=e.charCodeAt(0)+128;_=String.fromCharCode(t)}(s&&"escape"==this._altSendsWhat||c&&this._metaSendsEscape)&&(_=o.ESC+e)}"string"==typeof _?this._output(_):console.warn("action is not a string",_)}else console.log("Invalid action: "+JSON.stringify(_))}},this._onIME=e=>{let t=e.type,a=e.data||"";o.op("ime",{type:t,data:a}),"compositionend"==t&&this._output(a)},this._output=e=>{this._up.clear(),this.element.value=" ",this.element.selectionStart=1,this.element.selectionEnd=1,e&&o.op("out",{data:e})},this._stateReset=e=>{this._down.clear(),this._up.clear(),this._mods={Shift:new Set,Alt:new Set,Meta:new Set,Control:new Set},this.element.value=" ",this.element.selectionStart=1,this.element.selectionEnd=1,this.hasSelection=e},this._configKey=e=>{let t=e.code,a=h(e.down);a&&(this._downMap[t.id]=a),this._mod(e.mod)&&(this._modsMap[t.code]=e.mod);let o=h(e.up);o&&(this._upMap[t.id]=o),"AltRight"!=t.code&&"AltLeft"!=t.code||(this._ignoreAccents[t.code]=e.ignoreAccents)},this._config=e=>{this._reset(),this._bindings.reset(),this._configKey(e.capsLock),this._configKey(e.command.left),this._configKey(e.command.right),this._configKey(e.control.left),this._configKey(e.control.right),this._configKey(e.option.left),this._configKey(e.option.right),this._configKey(e.shift.left),this._configKey(e.shift.right),this._bindings.expandFn(e.fn),this._bindings.expandCursor(e.cursor);for(let t of e.shortcuts){let e={keys:this._keysFromShortcut(t.input,t.modifiers),action:t.action,shiftLoc:0,controlLoc:0,optionLoc:0,commandLoc:0};this._bindings.expandBinding(e)}},this._onToolbarMods=e=>{let t=s.UIKitFlagsToObject(e);t.alt?this._mods.Alt.add("tb-alt"):this._mods.Alt.delete("tb-alt"),t.ctrl?this._mods.Control.add("tb-ctrl"):this._mods.Control.delete("tb-ctrl"),t.shift?this._mods.Shift.add("tb-shift"):this._mods.Shift.delete("tb-shift"),t.meta?this._mods.Meta.add("tb-meta"):this._mods.Meta.delete("tb-meta")},this._execPress=(e,t,a)=>{let o=e.split(/:/g),l=this._mods;this._mods={Shift:new Set,Alt:new Set,Meta:new Set,Control:new Set};let n=parseInt(o[0],10),r=s.UIKitFlagsToObject(n);r.shift&&this._mods.Shift.add("tb-shift"),r.ctrl&&this._mods.Control.add("tb-ctrl"),r.alt&&this._mods.Alt.add("tb-alt"),r.meta&&this._mods.Meta.add("tb-meta");let i=parseInt(o[1],10),d=""==o[3]?":":o[3]||this._keyMap.key(i)||"",c={keyCode:i,key:d,code:"",src:"toolbar"};if(!a&&n>0){let e=c.keyCode+":"+o[2]+(0==i?":"+d:"");this._down.add(e);let t=this._bindings.match(this._downKeysIds());if(this._down.delete(e),t)return this._execBinding(t,null),void(this._mods=l)}this._handleKeyDownKey(c,t),this._mods=l,this._removeAccents=!0},this.onKB=(e,t)=>{switch(e){case"mods-down":this._handleCapsLockDown(!0);break;case"mods-up":this._handleCapsLockDown(!1);break;case"guard-up":this._handleGuard(!0,t);break;case"guard-down":this._handleGuard(!1,t);break;case"selection":this.hasSelection=t;break;case"lang":this._handleLang(t);break;case"toolbar-mods":this._onToolbarMods(t);break;case"toolbar-press":this._execPress(t,null,!1);break;case"press":this._execPress(t,null,!0);break;case"state-reset":this._stateReset(t);break;case"focus":this.focus(t);break;case"hex":this._output(c(t)),this._removeAccents=!0;break;case"config":this._config(t)}};let e=this.element;e.setAttribute("autocomplete","off"),e.setAttribute("spellcheck","false"),e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","none"),e.setAttribute("autofocus","true"),e.value=" ",e.addEventListener("keydown",this._onKeyDown),e.addEventListener("keyup",this._onKeyUp),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),e.addEventListener("compositionstart",this._onIME),e.addEventListener("compositionupdate",this._onIME),e.addEventListener("compositionend",this._onIME),e.addEventListener("beforeinput",this._onBeforeInput),e.addEventListener("input",this._onInput),this._capsLockRemapped=null!=this._modsMap.CapsLock||null!=this._downMap[u]||null!=this._upMap[u],this._shiftRemapped=null!=this._modsMap.Shift||"Shift"!==this._modsMap.Shift}_mod(e){switch(e){case"Escape":return this._altSendsWhat="escape","Alt";case"8-bit":return this._altSendsWhat="8-bit","Alt";case"Shift":return"Shift";case"Control":return"Control";case"Meta":return this._metaSendsEscape=!1,"Meta";case"Meta-Escape":return this._metaSendsEscape=!0,"Meta";default:return null}}focus(e){e?this.element.focus():this.element.blur()}ready(){o.op("ready",{})}_handleCapsLockDown(e){let t=this._modsMap.CapsLock;if(e){this._down.add(u);let e=this._downMap[u];return!e||t&&this._mods[t].has(u)||this._handleKeyDownKey(e,null),t&&this._mods[t].add(u),void(this._upMap[u]&&this._up.add(u))}this._down.delete(u),t&&this._mods[t].delete(u);let a=this._upMap[u];a&&this._up.has(u)&&this._handleKeyDownKey(a,null)}_handleLang(e){this._lang=e,this._langWithDeletes="ko-KR"===e,this._stateReset(this.hasSelection),"dictation"!=e&&o.op("voice",{data:""})}_handleGuard(e,t){this.element.value=" ";let a=this._keyMap.keyCode(t),o=`${a}:0`;if(e)return this._down.delete(o),void(this._removeAccents=!0);this._down.add(o),this._handleKeyDown(a,null)}_reset(){this.hasSelection=!1,this._removeAccents=!1,this._modsMap={},this._downMap={},this._upMap={},this._up.clear(),this._down.clear(),this._mods={Shift:new Set,Alt:new Set,Meta:new Set,Control:new Set},this._ignoreAccents={AltLeft:!0,AltRight:!0}}_keysFromShortcut(e,t){var a=[];let o=s.UIKitFlagsToObject(t);o.shift&&a.push(m),o.alt&&a.push(C),o.ctrl&&a.push(p),o.meta&&a.push(k);let l=this._keyMap.keyCode(e);return l?a.push(l+":0"):a.push("0:0-"+e),a}_execBinding(e,t){switch(e.type){case"command":o.op("command",{command:e.value});break;case"press":this._execPress(`${e.mods}:${e.key.id}`,t,!0);break;case"hex":this._output(c(e.value)),this._removeAccents=!0}}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=Symbol("CANCEL"),s=Symbol("DEFAULT"),l=Symbol("PASS"),n=Symbol("STRIP");function r(e,t){let a=Object.assign(Object.assign({},t),{op:e});window.webkit.messageHandlers._kb.postMessage(a)}t.KBActions={CANCEL:o,DEFAULT:s,PASS:l,STRIP:n},t.op=r;const i="O";t.ESC="",t.CSI="[",t.DEL="";const d=e=>String.fromCharCode(e.charCodeAt(0)-64),c={keyCode:0,keyCap:"[Unidentified]",normal:l,ctrl:l,alt:l,meta:l};t.default=class{constructor(e){this._defs={},this._reverseDefs={},this._onCtrlNum=(e,a)=>{switch(a.keyCap.substr(0,1)){case"1":return"1";case"2":return d("@");case"3":return d("[");case"4":return d("\\");case"5":return d("]");case"6":return d("^");case"7":return d("_");case"8":return t.DEL;case"9":return"9";default:return l}},this._onAltNum=(e,t)=>s,this._onSel=(e,t)=>{let{ArrowDown:a,ArrowLeft:s,ArrowRight:l,ArrowUp:n,Escape:i,h:d,j:c,k:h,l:y,o:m,b:p,f:C,n:k,p:u,w:_,x:f,y:g}=this._reverseDefs;const S=e=>r("selection",e),w={command:"copy"};if(t===s||t===d){S({dir:"left",gran:e.shift?"word":"character"})}else if(t===l||t===y){S({dir:"right",gran:e.shift?"word":"character"})}else t===n||t===h?S({dir:"left",gran:"line"}):t===a||t===c?S({dir:"right",gran:"line"}):t===m||t===f?S({command:"change"}):t===k&&e.ctrl?S({dir:"right",gran:"line"}):t===u?e.ctrl?S({dir:"left",gran:"line"}):e.shift||e.alt||e.meta||S({command:"paste"}):t===p?e.ctrl?S({dir:"left",gran:"character"}):(e.alt,S({dir:"left",gran:"word"})):t===_?e.alt?S(w):S({dir:"right",gran:"word"}):t===C?e.ctrl?S({dir:"right",gran:"character"}):e.alt&&S({dir:"right",gran:"word"}):t===g?S(w):t===i&&S({command:"cancel"});return o},this._keyboard=e,this.reset()}getKeyDef(e){var t=this._defs[e];return t||(console.warn(`No definition for (keyCode ${e})`),t=c,this.addKeyDef(e,t),t)}addKeyDef(e,t){if(e in this._defs&&console.warn("Dup keyCode: ",e),this._defs[e]=t,/^\[\w+\]$/.test(t.keyCap)){let e=t.keyCap.replace(/\W/g,"");this._reverseDefs[e]=t}else{var a=t.keyCap[0];this._reverseDefs[a]=t,/0-9/.test(a)?this._reverseDefs["Digit"+a]=t:/[a-z]/.test(a)&&(this._reverseDefs["Key"+a.toUpperCase()]=t)}}reset(){this._defs={};const e=(e,t,a)=>"function"==typeof e?e.call(this,t,a):e,a=(t,a)=>(o,s)=>{let l=o.shift||o.ctrl||o.alt||o.meta?a:t;return e(l,o,s)},o=(t,a)=>(o,s)=>{let l=o.shift?a:t;return o.shift=!1,e(l,o,s)},r=(e,t)=>e,h=(t,a)=>(o,s)=>{let l=o.alt?t:a;return e(l,o,s)},y=(t,a)=>(o,s)=>{let l=o.shift||o.ctrl||o.alt||o.meta?t:a;return e(l,o,s)},m=t=>(a,o)=>{let s=this._keyboard.hasSelection?this._onSel:t;return e(s,a,o)},p=e=>this.addKeyDef(e.keyCode,e);p(c),p({keyCode:27,keyCap:"[Escape]",normal:m(t.ESC),ctrl:s,alt:s,meta:s}),p({keyCode:112,keyCap:"[F1]",normal:a(i+"P",t.CSI+"P"),ctrl:s,alt:t.CSI+"23~",meta:s}),p({keyCode:113,keyCap:"[F2]",normal:a(i+"Q",t.CSI+"Q"),ctrl:s,alt:t.CSI+"24~",meta:s}),p({keyCode:114,keyCap:"[F3]",normal:a(i+"R",t.CSI+"R"),ctrl:s,alt:t.CSI+"25~",meta:s}),p({keyCode:115,keyCap:"[F4]",normal:a(i+"S",t.CSI+"S"),ctrl:s,alt:t.CSI+"26~",meta:s}),p({keyCode:116,keyCap:"[F5]",normal:t.CSI+"15~",ctrl:s,alt:t.CSI+"28~",meta:s}),p({keyCode:117,keyCap:"[F6]",normal:t.CSI+"17~",ctrl:s,alt:t.CSI+"29~",meta:s}),p({keyCode:118,keyCap:"[F7]",normal:t.CSI+"18~",ctrl:s,alt:t.CSI+"31~",meta:s}),p({keyCode:119,keyCap:"[F8]",normal:t.CSI+"19~",ctrl:s,alt:t.CSI+"32~",meta:s}),p({keyCode:120,keyCap:"[F9]",normal:t.CSI+"20~",ctrl:s,alt:t.CSI+"33~",meta:s}),p({keyCode:121,keyCap:"[F10]",normal:t.CSI+"21~",ctrl:s,alt:t.CSI+"34~",meta:s}),p({keyCode:122,keyCap:"[F11]",normal:t.CSI+"23~",ctrl:s,alt:t.CSI+"42~",meta:s}),p({keyCode:123,keyCap:"[F12]",normal:t.CSI+"24~",ctrl:s,alt:t.CSI+"43~",meta:s});const C=this._onCtrlNum,k=this._onAltNum;p({keyCode:192,keyCap:"`~",normal:s,ctrl:o(d("@"),d("^")),alt:s,meta:s}),p({keyCode:49,keyCap:"1!",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:50,keyCap:"2@",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:51,keyCap:"3#",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:52,keyCap:"4$",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:53,keyCap:"5%",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:54,keyCap:"6^",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:55,keyCap:"7&",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:56,keyCap:"8*",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:57,keyCap:"9(",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:48,keyCap:"0)",normal:s,ctrl:s,alt:k,meta:s}),p({keyCode:189,keyCap:"-_",normal:s,ctrl:d("_"),alt:s,meta:s}),p({keyCode:187,keyCap:"=+",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:8,keyCap:"[Backspace]",normal:r(t.DEL),ctrl:r("\b",t.DEL),alt:s,meta:s}),p({keyCode:9,keyCap:"[Tab]",normal:o("\t",t.CSI+"Z"),ctrl:n,alt:n,meta:s}),p({keyCode:81,keyCap:"qQ",normal:s,ctrl:d("Q"),alt:s,meta:s}),p({keyCode:87,keyCap:"wW",normal:m(s),ctrl:d("W"),alt:m(s),meta:s}),p({keyCode:69,keyCap:"eE",normal:s,ctrl:d("E"),alt:s,meta:s}),p({keyCode:82,keyCap:"rR",normal:s,ctrl:d("R"),alt:s,meta:s}),p({keyCode:84,keyCap:"tT",normal:s,ctrl:d("T"),alt:s,meta:s}),p({keyCode:89,keyCap:"yY",normal:m(s),ctrl:d("Y"),alt:s,meta:s}),p({keyCode:85,keyCap:"uU",normal:s,ctrl:d("U"),alt:s,meta:s}),p({keyCode:73,keyCap:"iI",normal:s,ctrl:d("I"),alt:s,meta:s}),p({keyCode:79,keyCap:"oO",normal:m(s),ctrl:d("O"),alt:s,meta:s}),p({keyCode:80,keyCap:"pP",normal:m(s),ctrl:m(d("P")),alt:s,meta:s}),p({keyCode:219,keyCap:"[{",normal:s,ctrl:d("["),alt:s,meta:s}),p({keyCode:221,keyCap:"]}",normal:s,ctrl:d("]"),alt:s,meta:s}),p({keyCode:220,keyCap:"\\|",normal:s,ctrl:d("\\"),alt:s,meta:s}),p({keyCode:20,keyCap:"[CapsLock]",normal:l,ctrl:l,alt:l,meta:s}),p({keyCode:65,keyCap:"aA",normal:s,ctrl:d("A"),alt:s,meta:s}),p({keyCode:83,keyCap:"sS",normal:s,ctrl:d("S"),alt:s,meta:s}),p({keyCode:68,keyCap:"dD",normal:s,ctrl:d("D"),alt:s,meta:s}),p({keyCode:70,keyCap:"fF",normal:s,ctrl:m(d("F")),alt:m(s),meta:s}),p({keyCode:71,keyCap:"gG",normal:s,ctrl:d("G"),alt:s,meta:s}),p({keyCode:72,keyCap:"hH",normal:m(s),ctrl:d("H"),alt:s,meta:s}),p({keyCode:74,keyCap:"jJ",normal:m(s),ctrl:d("J"),alt:s,meta:s}),p({keyCode:75,keyCap:"kK",normal:m(s),ctrl:d("K"),alt:s,meta:s}),p({keyCode:76,keyCap:"lL",normal:m(s),ctrl:d("L"),alt:s,meta:s}),p({keyCode:186,keyCap:";:",normal:s,ctrl:n,alt:s,meta:s}),p({keyCode:222,keyCap:"'\"",normal:s,ctrl:n,alt:s,meta:s}),p({keyCode:13,keyCap:"[Enter]",normal:"\r",ctrl:s,alt:s,meta:s}),p({keyCode:16,keyCap:"[Shift]",normal:l,ctrl:l,alt:l,meta:s}),p({keyCode:90,keyCap:"zZ",normal:s,ctrl:d("Z"),alt:s,meta:s}),p({keyCode:88,keyCap:"xX",normal:m(s),ctrl:m(d("X")),alt:s,meta:s}),p({keyCode:67,keyCap:"cC",normal:s,ctrl:d("C"),alt:s,meta:s}),p({keyCode:86,keyCap:"vV",normal:s,ctrl:d("V"),alt:s,meta:s}),p({keyCode:66,keyCap:"bB",normal:m(s),ctrl:m(d("B")),alt:m(s),meta:s}),p({keyCode:78,keyCap:"nN",normal:s,ctrl:m(d("N")),alt:s,meta:s}),p({keyCode:77,keyCap:"mM",normal:s,ctrl:d("M"),alt:s,meta:s}),p({keyCode:188,keyCap:",<",normal:s,ctrl:h(n,l),alt:s,meta:s}),p({keyCode:190,keyCap:".>",normal:s,ctrl:h(n,l),alt:s,meta:s}),p({keyCode:191,keyCap:"/?",normal:s,ctrl:o(d("_"),d("?")),alt:s,meta:s}),p({keyCode:17,keyCap:"[Control]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:18,keyCap:"[Alt]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:91,keyCap:"[Meta]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:32,keyCap:" ",normal:s,ctrl:d("@"),alt:s,meta:s}),p({keyCode:93,keyCap:"[Meta]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:42,keyCap:"[PRTSCR]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:145,keyCap:"[SCRLK]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:19,keyCap:"[BREAK]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:45,keyCap:"[Insert]",normal:t.CSI+"2~",ctrl:s,alt:s,meta:s}),p({keyCode:36,keyCap:"[Home]",normal:t.ESC+"OH",ctrl:s,alt:s,meta:s}),p({keyCode:33,keyCap:"[PageUp]",normal:t.CSI+"5~",ctrl:s,alt:s,meta:s}),p({keyCode:46,keyCap:"[DEL]",normal:t.CSI+"3~",ctrl:s,alt:s,meta:s}),p({keyCode:35,keyCap:"[End]",normal:t.ESC+"OF",ctrl:s,alt:s,meta:s}),p({keyCode:34,keyCap:"[PageDown]",normal:t.CSI+"6~",ctrl:s,alt:s,meta:s}),p({keyCode:38,keyCap:"[ArrowUp]",normal:m(y(t.CSI+"A",i+"A")),ctrl:s,alt:s,meta:s}),p({keyCode:40,keyCap:"[ArrowDown]",normal:m(y(t.CSI+"B",i+"B")),ctrl:s,alt:s,meta:s}),p({keyCode:39,keyCap:"[ArrowRight]",normal:m(y(t.CSI+"C",i+"C")),ctrl:s,alt:s,meta:s}),p({keyCode:37,keyCap:"[ArrowLeft]",normal:m(y(t.CSI+"D",i+"D")),ctrl:s,alt:s,meta:s}),p({keyCode:144,keyCap:"[NumLock]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:12,keyCap:"[Clear]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:96,keyCap:"[Numpad0]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:97,keyCap:"[Numpad1]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:98,keyCap:"[Numpad2]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:99,keyCap:"[Numpad3]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:100,keyCap:"[Numpad4]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:101,keyCap:"[Numpad5]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:102,keyCap:"[Numpad6]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:103,keyCap:"[Numpad7]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:104,keyCap:"[Numpad8]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:105,keyCap:"[Numpad9]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:107,keyCap:"[NumpadAdd]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:109,keyCap:"[NumpadSubtract]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:106,keyCap:"[NumpadMultiply]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:111,keyCap:"[NumpadDivide]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:110,keyCap:"[NumpadDicimal]",normal:s,ctrl:s,alt:s,meta:s}),this._reverseDefs.Backqoute=this._defs[192],this._reverseDefs.BracketLeft=this._defs[229],this._reverseDefs.BracketRight=this._defs[221],this._reverseDefs.Slash=this._defs[191],this._reverseDefs.Space=this._defs[32]}keyCode(e){let t=this._reverseDefs[e];return t?t.keyCode:0}key(e){let t=this._defs[e];if(!t)return"";let a=t.keyCap;return/^\[\w+\]$/.test(a)?a.substr(1,a.length-2):a.substr(0,1)}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=65536,s=1<<17,l=1<<18,n=1<<19,r=1<<20;t.toUIKitFlags=function(e,t=!0){let a=0;return e.shiftKey&&(a|=s),e.ctrlKey&&(a|=l),e.altKey&&(a|=n),e.metaKey&&(a|=r),t&&(a|=o),a},t.UIKitFlagsToObject=function(e){return{shift:(e&s)==s,alt:(e&n)==n,ctrl:(e&l)==l,meta:(e&r)==r}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this._map={},this.expandFn=e=>{if(0===e.keys.length)return;let t=[{keyCode:121,key:"F10",code:"F10",id:"121:0"},{keyCode:112,key:"F1",code:"F1",id:"112:0"},{keyCode:113,key:"F2",code:"F2",id:"113:0"},{keyCode:114,key:"F3",code:"F3",id:"114:0"},{keyCode:115,key:"F4",code:"F4",id:"115:0"},{keyCode:116,key:"F5",code:"F5",id:"116:0"},{keyCode:117,key:"F6",code:"F6",id:"117:0"},{keyCode:118,key:"F7",code:"F7",id:"118:0"},{keyCode:119,key:"F8",code:"F8",id:"119:0"},{keyCode:120,key:"F9",code:"F9",id:"120:0"}],a=e.keys.slice();for(var o=0;o<10;o++){let s=o+48+":0",l=t[o];e.keys=a.slice(),e.keys.push(s),e.action={type:"press",key:l,mods:0},this.expandBinding(e)}},this.expandCursor=e=>{if(0==e.keys.length)return;let t=[{keyCode:36,key:"HOME",code:"HOME",id:"36:0"},{keyCode:33,key:"PGUP",code:"PGUP",id:"33:0"},{keyCode:35,key:"END",code:"END",id:"35:0"},{keyCode:34,key:"PGDOWN",code:"PGDOWN",id:"34:0"}],a=["37:0","38:0","39:0","40:0"],o=e.keys.slice();for(var s=0;s{var t=e.keys.map(e=>e.split("-")[0]);if(0==t.length)return;var a=[t.sort()],o=0;var s=[{idLeft:"16:1",idRight:"16:2",loc:e.shiftLoc},{idLeft:"17:1",idRight:"17:2",loc:e.controlLoc},{idLeft:"18:1",idRight:"18:2",loc:e.optionLoc},{idLeft:"91:1",idRight:"93:0",loc:e.commandLoc}];for(let e of s)for(o=a.length-1;o>=0;o--){var l=a[o];let t=l.indexOf(e.idLeft);if(t<0&&(t=l.indexOf(e.idRight)),t<0)continue;if(1==e.loc){l[t]=e.idLeft;continue}if(2==e.loc){l[t]=e.idRight;continue}l[t]=e.idLeft;let s=l.slice();s[t]=e.idRight,a.push(s)}for(let t of a){let a=t.sort().join(":");this._map[a]=e.action}}}reset(){this._map={}}match(e){let t=e.sort().join(":");return this._map[t]}}}]);
\ No newline at end of file
+!function(e){var t={};function a(o){if(t[o])return t[o].exports;var s=t[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,a),s.l=!0,s.exports}a.m=e,a.c=t,a.d=function(e,t,o){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(a.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)a.d(o,s,function(t){return e[t]}.bind(null,s));return o},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=0)}([function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=new(a(1).default);document.body.append(o.element),o.focus(!0),window._onKB=o.onKB,window._kb=o,o.ready()},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=a(2),s=a(3),l=a(4),n=o.KBActions.CANCEL,i=o.KBActions.DEFAULT,r=o.KBActions.PASS,d=o.KBActions.STRIP;function c(e){let t="",a=e.length;for(let o=0;o{let t=e.code;if(this._capsLockRemapped){let a;a="keyup"==e.type&&"CapsLock"==t?0:s.toUIKitFlags(e),o.op("mods",{mods:a})}"AltLeft"!=t&&"AltRight"!=t||this._ignoreAccents[t]&&("keydown"==e.type?o.op("guard-ime-on",{}):o.op("guard-ime-off",{}),f(e))},this._downKeysIds=()=>{let e=Array.from(this._down);return this._mods.Meta.has("tb-meta")&&-1==e.indexOf(k)&&e.push(k),this._mods.Control.has("tb-ctrl")&&-1==e.indexOf(p)&&e.push(p),this._mods.Alt.has("tb-alt")&&-1==e.indexOf(C)&&e.push(C),this._mods.Shift.has("tb-shift")&&-1==e.indexOf(m)&&e.push(m),e},this._onKeyDown=e=>{if(e.isComposing)return void(this._lastKeyDownEvent=null);let t=e;if(229===e.keyCode){if(!this._lastKeyDownEvent)return;t=this._lastKeyDownEvent}else this._lastKeyDownEvent=e;let a=_(t);this._down.add(a);let o=this._bindings.match(this._downKeysIds());if(y.has(a)||this._down.delete(a),o)return this._execBinding(o,e),void f(e);let s=this._downMap[a],l=this._mod(this._modsMap[t.code]),n=!1;s&&((n=!(l&&this._mods[l].has(a)))||(this._handleKeyDownKey(s,e),n=!0)),l&&this._mods[l].add(a),this._upMap[a]&&this._up.add(a),this._updateUIKitModsIfNeeded(t),n||this._handleKeyDown(t.keyCode,e)},this._onBeforeInput=e=>{if("dictation"!==this._lang){if("insertText"===e.inputType&&(this._output(e.data),this._langWithDeletes&&e.data)){this.element.value=e.data;let t=e.data.length;this.element.selectionStart=t,this.element.selectionEnd=t}"deleteContentBackward"===e.inputType&&this._output(o.DEL),f(e)}else o.op("voice",{data:e.data||""})},this._onInput=e=>f(e),this._onKeyUp=e=>{this._lastKeyDownEvent=null;let t=_(e);this._down.delete(t);let a=this._mod(this._modsMap[e.code]);a&&this._mods[a].delete(t),this._updateUIKitModsIfNeeded(e);let o=this._upMap[t];o&&this._up.has(t)&&this._handleKeyDownKey(o,null),f(e)},this._handleKeyDown=(e,t)=>{let a={keyCode:e,key:"",code:"Unidentified"};t&&(a.code=t.code,a.key=t.key),this._handleKeyDownKey(a,t)},this._handleKeyDownKey=(e,t)=>{let a=this._keyMap,s=this._mods.Alt.size>0,l=this._mods.Control.size>0,c=this._mods.Meta.size>0,h=this._mods.Shift.size>0,y=e.code,m=e.key,p=function(e,t,a){if(!a)return e;if(a.ctrlKey){let o=a.key.toLowerCase(),s=a.keyCode;if(8===s&&"h"===o||9===s&&"i"===o||13===s&&"c"===o||13===s&&"m"===o||27===s&&"["===o)return e.keyCode=t.keyCode(o)||e.keyCode,e;let l=a.code;(8===s&&"KeyH"===l||9===s&&"KeyI"===l||13===s&&"KeyC"===l||13===s&&"KeyM"===l||27===s&&"BracketLeft"===l)&&(e.keyCode=t.keyCode(l)||e.keyCode)}return e}({key:m,code:y,keyCode:e.keyCode,alt:s,ctrl:l,meta:c,shift:h},this._keyMap,t),C=a.getKeyDef(p.keyCode);var k=null;function u(e){k=e;var t=C[e];return"function"==typeof t&&(t=t.call(a,p,C)),t===i&&"normal"!==e&&(t=u("normal")),t}let _;if(_=u(l?"ctrl":s?"alt":c?"meta":"normal"),!this._langWithDeletes||"[Backspace]"!==C.keyCap){if(!this.hasSelection&&(_===r||_===i&&!(l||s||c))){if(_===r&&!e.src)return;if(/^\[\w+\]$/.test(C.keyCap)){if(!e.src)return void(this._removeAccents=!1)}else if(this._langWithDeletes)return;if(!this._isHKB)return this._output(m),void f(t);let a=this._removeAccents?function(e){let t=e.normalize("NFD").replace(/[\u0300-\u036f]/g,""),a=t.replace(/^[\u02c6\u00a8\u00b4\u02dc\u0060]/,"");return a&&(t=a),t}(m):m;return this._removeAccents=!1,this._capsLockRemapped||this._shiftRemapped?this._output(h?a.toUpperCase():a.toLowerCase()):this._output(a),void f(t)}if(this._removeAccents=!1,_===d&&(s=l=!1,"function"==typeof(_=C.normal)&&(_=_.call(a,p,C)),_===i&&2===C.keyCap.length&&(_=C.keyCap.substr(h?1:0,1))),f(t),_!==n&&!this.hasSelection)if(_===i||"string"==typeof _){if("ctrl"===k?l=!1:"alt"===k?s=!1:"meta"===k&&(c=!1),h=p.shift,(s||l||h||c)&&"string"==typeof _&&_.substr(0,2)===o.CSI){let e=1;h&&(e+=1),s&&(e+=2),l&&(e+=4),c&&(e+=8);let t=";"+e;_=3==_.length?o.CSI+"1"+t+_.substr(2,1):_.substr(0,_.length-1)+t+_.substr(_.length-1)}else{if(_===i&&(_=C.keyCap.substr(h?1:0,1),l)){let e=C.keyCap.substr(0,1).charCodeAt(0);e>=64&&e<=95&&(_=String.fromCharCode(e-64))}let e=_.toString();if(s&&"8-bit"==this._altSendsWhat&&1==e.length){let t=e.charCodeAt(0)+128;_=String.fromCharCode(t)}(s&&"escape"==this._altSendsWhat||c&&this._metaSendsEscape)&&(_=o.ESC+e)}"string"==typeof _?this._output(_):console.warn("action is not a string",_)}else console.log("Invalid action: "+JSON.stringify(_))}},this._onIME=e=>{let t=e.type,a=e.data||"";o.op("ime",{type:t,data:a}),"compositionend"==t&&this._output(a)},this._output=e=>{this._up.clear(),this.element.value=" ",this.element.selectionStart=1,this.element.selectionEnd=1,e&&o.op("out",{data:e})},this._stateReset=e=>{this._down.clear(),this._up.clear(),this._mods={Shift:new Set,Alt:new Set,Meta:new Set,Control:new Set},this.element.value=" ",this.element.selectionStart=1,this.element.selectionEnd=1,this.hasSelection=e},this._configKey=e=>{let t=e.code,a=h(e.down);a&&(this._downMap[t.id]=a),this._mod(e.mod)&&(this._modsMap[t.code]=e.mod);let o=h(e.up);o&&(this._upMap[t.id]=o),"AltRight"!=t.code&&"AltLeft"!=t.code||(this._ignoreAccents[t.code]=e.ignoreAccents)},this._config=e=>{this._reset(),this._bindings.reset(),this._configKey(e.capsLock),this._configKey(e.command.left),this._configKey(e.command.right),this._configKey(e.control.left),this._configKey(e.control.right),this._configKey(e.option.left),this._configKey(e.option.right),this._configKey(e.shift.left),this._configKey(e.shift.right),this._bindings.expandFn(e.fn),this._bindings.expandCursor(e.cursor);for(let t of e.shortcuts){let e={keys:this._keysFromShortcut(t.input,t.modifiers),action:t.action,shiftLoc:0,controlLoc:0,optionLoc:0,commandLoc:0};this._bindings.expandBinding(e)}},this._onToolbarMods=e=>{let t=s.UIKitFlagsToObject(e);t.alt?this._mods.Alt.add("tb-alt"):this._mods.Alt.delete("tb-alt"),t.ctrl?this._mods.Control.add("tb-ctrl"):this._mods.Control.delete("tb-ctrl"),t.shift?this._mods.Shift.add("tb-shift"):this._mods.Shift.delete("tb-shift"),t.meta?this._mods.Meta.add("tb-meta"):this._mods.Meta.delete("tb-meta")},this._execPress=(e,t,a)=>{let o=e.split(/:/g),l=this._mods;this._mods={Shift:new Set,Alt:new Set,Meta:new Set,Control:new Set};let n=parseInt(o[0],10),i=s.UIKitFlagsToObject(n);i.shift&&this._mods.Shift.add("tb-shift"),i.ctrl&&this._mods.Control.add("tb-ctrl"),i.alt&&this._mods.Alt.add("tb-alt"),i.meta&&this._mods.Meta.add("tb-meta");let r=parseInt(o[1],10),d=""==o[3]?":":o[3]||this._keyMap.key(r)||"",c={keyCode:r,key:d,code:"",src:"toolbar"};if(!a&&n>0){let e=c.keyCode+":"+o[2]+(0==r?":"+d:"");this._down.add(e);let t=this._bindings.match(this._downKeysIds());if(this._down.delete(e),t)return this._execBinding(t,null),void(this._mods=l)}this._handleKeyDownKey(c,t),this._mods=l,this._removeAccents=!0},this.onKB=(e,t)=>{switch(e){case"mods-down":this._handleCapsLockDown(!0);break;case"mods-up":this._handleCapsLockDown(!1);break;case"guard-up":this._handleGuard(!0,t);break;case"guard-down":this._handleGuard(!1,t);break;case"selection":this.hasSelection=t;break;case"lang":this._handleLang(t);break;case"toolbar-mods":this._onToolbarMods(t);break;case"toolbar-press":this._execPress(t,null,!1);break;case"press":this._execPress(t,null,!0);break;case"state-reset":this._stateReset(t);break;case"focus":this.focus(t);break;case"hex":this._output(c(t)),this._removeAccents=!0;break;case"config":this._config(t)}};let e=this.element;e.setAttribute("autocomplete","off"),e.setAttribute("spellcheck","false"),e.setAttribute("autocorrect","off"),e.setAttribute("autocapitalize","none"),e.setAttribute("autofocus","true"),e.value=" ",e.addEventListener("keydown",this._onKeyDown),e.addEventListener("keyup",this._onKeyUp),window.addEventListener("keydown",this._onKeyDown),window.addEventListener("keyup",this._onKeyUp),e.addEventListener("compositionstart",this._onIME),e.addEventListener("compositionupdate",this._onIME),e.addEventListener("compositionend",this._onIME),e.addEventListener("beforeinput",this._onBeforeInput),e.addEventListener("input",this._onInput),this._capsLockRemapped=null!=this._modsMap.CapsLock||null!=this._downMap[u]||null!=this._upMap[u],this._shiftRemapped=null!=this._modsMap.Shift||"Shift"!==this._modsMap.Shift}_mod(e){switch(e){case"Escape":return this._altSendsWhat="escape","Alt";case"8-bit":return this._altSendsWhat="8-bit","Alt";case"Shift":return"Shift";case"Control":return"Control";case"Meta":return this._metaSendsEscape=!1,"Meta";case"Meta-Escape":return this._metaSendsEscape=!0,"Meta";default:return null}}focus(e){e?this.element.focus():this.element.blur()}ready(){o.op("ready",{})}_handleCapsLockDown(e){let t=this._modsMap.CapsLock;if(e){this._down.add(u);let e=this._downMap[u];return!e||t&&this._mods[t].has(u)||this._handleKeyDownKey(e,null),t&&this._mods[t].add(u),void(this._upMap[u]&&this._up.add(u))}this._down.delete(u),t&&this._mods[t].delete(u);let a=this._upMap[u];a&&this._up.has(u)&&this._handleKeyDownKey(a,null)}_handleLang(e){let t=e.split(":");this._lang=t[0],this._isHKB="hw"===t[1],this._langWithDeletes="ko-KR"===this._lang,this._stateReset(this.hasSelection),"dictation"!==this._lang&&o.op("voice",{data:""})}_handleGuard(e,t){this.element.value=" ";let a=this._keyMap.keyCode(t),o=`${a}:0`;if(e)return this._down.delete(o),void(this._removeAccents=!0);this._down.add(o),this._handleKeyDown(a,null)}_reset(){this.hasSelection=!1,this._removeAccents=!1,this._modsMap={},this._downMap={},this._upMap={},this._up.clear(),this._down.clear(),this._mods={Shift:new Set,Alt:new Set,Meta:new Set,Control:new Set},this._ignoreAccents={AltLeft:!0,AltRight:!0}}_keysFromShortcut(e,t){var a=[];let o=s.UIKitFlagsToObject(t);o.shift&&a.push(m),o.alt&&a.push(C),o.ctrl&&a.push(p),o.meta&&a.push(k);let l=this._keyMap.keyCode(e);return l?a.push(l+":0"):a.push("0:0-"+e),a}_execBinding(e,t){switch(e.type){case"command":o.op("command",{command:e.value});break;case"press":this._execPress(`${e.mods}:${e.key.id}`,t,!0);break;case"hex":this._output(c(e.value)),this._removeAccents=!0}}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=Symbol("CANCEL"),s=Symbol("DEFAULT"),l=Symbol("PASS"),n=Symbol("STRIP");function i(e,t){let a=Object.assign(Object.assign({},t),{op:e});window.webkit.messageHandlers._kb.postMessage(a)}t.KBActions={CANCEL:o,DEFAULT:s,PASS:l,STRIP:n},t.op=i;const r="O";t.ESC="",t.CSI="[",t.DEL="";const d=e=>String.fromCharCode(e.charCodeAt(0)-64),c={keyCode:0,keyCap:"[Unidentified]",normal:l,ctrl:l,alt:l,meta:l};t.default=class{constructor(e){this._defs={},this._reverseDefs={},this._onCtrlNum=(e,a)=>{switch(a.keyCap.substr(0,1)){case"1":return"1";case"2":return d("@");case"3":return d("[");case"4":return d("\\");case"5":return d("]");case"6":return d("^");case"7":return d("_");case"8":return t.DEL;case"9":return"9";default:return l}},this._onAltNum=(e,t)=>s,this._onSel=(e,t)=>{let{ArrowDown:a,ArrowLeft:s,ArrowRight:l,ArrowUp:n,Escape:r,h:d,j:c,k:h,l:y,o:m,b:p,f:C,n:k,p:u,w:_,x:f,y:g}=this._reverseDefs;const S=e=>i("selection",e),w={command:"copy"};if(t===s||t===d){S({dir:"left",gran:e.shift?"word":"character"})}else if(t===l||t===y){S({dir:"right",gran:e.shift?"word":"character"})}else t===n||t===h?S({dir:"left",gran:"line"}):t===a||t===c?S({dir:"right",gran:"line"}):t===m||t===f?S({command:"change"}):t===k&&e.ctrl?S({dir:"right",gran:"line"}):t===u?e.ctrl?S({dir:"left",gran:"line"}):e.shift||e.alt||e.meta||S({command:"paste"}):t===p?e.ctrl?S({dir:"left",gran:"character"}):(e.alt,S({dir:"left",gran:"word"})):t===_?e.alt?S(w):S({dir:"right",gran:"word"}):t===C?e.ctrl?S({dir:"right",gran:"character"}):e.alt&&S({dir:"right",gran:"word"}):t===g?S(w):t===r&&S({command:"cancel"});return o},this._keyboard=e,this.reset()}getKeyDef(e){var t=this._defs[e];return t||(console.warn(`No definition for (keyCode ${e})`),t=c,this.addKeyDef(e,t),t)}addKeyDef(e,t){if(e in this._defs&&console.warn("Dup keyCode: ",e),this._defs[e]=t,/^\[\w+\]$/.test(t.keyCap)){let e=t.keyCap.replace(/\W/g,"");this._reverseDefs[e]=t}else{var a=t.keyCap[0];this._reverseDefs[a]=t,/0-9/.test(a)?this._reverseDefs["Digit"+a]=t:/[a-z]/.test(a)&&(this._reverseDefs["Key"+a.toUpperCase()]=t)}}reset(){this._defs={};const e=(e,t,a)=>"function"==typeof e?e.call(this,t,a):e,a=(t,a)=>(o,s)=>{let l=o.shift||o.ctrl||o.alt||o.meta?a:t;return e(l,o,s)},o=(t,a)=>(o,s)=>{let l=o.shift?a:t;return o.shift=!1,e(l,o,s)},i=(e,t)=>e,h=(t,a)=>(o,s)=>{let l=o.alt?t:a;return e(l,o,s)},y=(t,a)=>(o,s)=>{let l=o.shift||o.ctrl||o.alt||o.meta?t:a;return e(l,o,s)},m=t=>(a,o)=>{let s=this._keyboard.hasSelection?this._onSel:t;return e(s,a,o)},p=e=>this.addKeyDef(e.keyCode,e);p(c),p({keyCode:27,keyCap:"[Escape]",normal:m(t.ESC),ctrl:s,alt:s,meta:s}),p({keyCode:112,keyCap:"[F1]",normal:a(r+"P",t.CSI+"P"),ctrl:s,alt:t.CSI+"23~",meta:s}),p({keyCode:113,keyCap:"[F2]",normal:a(r+"Q",t.CSI+"Q"),ctrl:s,alt:t.CSI+"24~",meta:s}),p({keyCode:114,keyCap:"[F3]",normal:a(r+"R",t.CSI+"R"),ctrl:s,alt:t.CSI+"25~",meta:s}),p({keyCode:115,keyCap:"[F4]",normal:a(r+"S",t.CSI+"S"),ctrl:s,alt:t.CSI+"26~",meta:s}),p({keyCode:116,keyCap:"[F5]",normal:t.CSI+"15~",ctrl:s,alt:t.CSI+"28~",meta:s}),p({keyCode:117,keyCap:"[F6]",normal:t.CSI+"17~",ctrl:s,alt:t.CSI+"29~",meta:s}),p({keyCode:118,keyCap:"[F7]",normal:t.CSI+"18~",ctrl:s,alt:t.CSI+"31~",meta:s}),p({keyCode:119,keyCap:"[F8]",normal:t.CSI+"19~",ctrl:s,alt:t.CSI+"32~",meta:s}),p({keyCode:120,keyCap:"[F9]",normal:t.CSI+"20~",ctrl:s,alt:t.CSI+"33~",meta:s}),p({keyCode:121,keyCap:"[F10]",normal:t.CSI+"21~",ctrl:s,alt:t.CSI+"34~",meta:s}),p({keyCode:122,keyCap:"[F11]",normal:t.CSI+"23~",ctrl:s,alt:t.CSI+"42~",meta:s}),p({keyCode:123,keyCap:"[F12]",normal:t.CSI+"24~",ctrl:s,alt:t.CSI+"43~",meta:s});const C=this._onCtrlNum,k=this._onAltNum;p({keyCode:192,keyCap:"`~",normal:s,ctrl:o(d("@"),d("^")),alt:s,meta:s}),p({keyCode:49,keyCap:"1!",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:50,keyCap:"2@",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:51,keyCap:"3#",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:52,keyCap:"4$",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:53,keyCap:"5%",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:54,keyCap:"6^",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:55,keyCap:"7&",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:56,keyCap:"8*",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:57,keyCap:"9(",normal:s,ctrl:C,alt:k,meta:s}),p({keyCode:48,keyCap:"0)",normal:s,ctrl:s,alt:k,meta:s}),p({keyCode:189,keyCap:"-_",normal:s,ctrl:d("_"),alt:s,meta:s}),p({keyCode:187,keyCap:"=+",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:8,keyCap:"[Backspace]",normal:i(t.DEL),ctrl:i("\b",t.DEL),alt:s,meta:s}),p({keyCode:9,keyCap:"[Tab]",normal:o("\t",t.CSI+"Z"),ctrl:n,alt:n,meta:s}),p({keyCode:81,keyCap:"qQ",normal:s,ctrl:d("Q"),alt:s,meta:s}),p({keyCode:87,keyCap:"wW",normal:m(s),ctrl:d("W"),alt:m(s),meta:s}),p({keyCode:69,keyCap:"eE",normal:s,ctrl:d("E"),alt:s,meta:s}),p({keyCode:82,keyCap:"rR",normal:s,ctrl:d("R"),alt:s,meta:s}),p({keyCode:84,keyCap:"tT",normal:s,ctrl:d("T"),alt:s,meta:s}),p({keyCode:89,keyCap:"yY",normal:m(s),ctrl:d("Y"),alt:s,meta:s}),p({keyCode:85,keyCap:"uU",normal:s,ctrl:d("U"),alt:s,meta:s}),p({keyCode:73,keyCap:"iI",normal:s,ctrl:d("I"),alt:s,meta:s}),p({keyCode:79,keyCap:"oO",normal:m(s),ctrl:d("O"),alt:s,meta:s}),p({keyCode:80,keyCap:"pP",normal:m(s),ctrl:m(d("P")),alt:s,meta:s}),p({keyCode:219,keyCap:"[{",normal:s,ctrl:d("["),alt:s,meta:s}),p({keyCode:221,keyCap:"]}",normal:s,ctrl:d("]"),alt:s,meta:s}),p({keyCode:220,keyCap:"\\|",normal:s,ctrl:d("\\"),alt:s,meta:s}),p({keyCode:20,keyCap:"[CapsLock]",normal:l,ctrl:l,alt:l,meta:s}),p({keyCode:65,keyCap:"aA",normal:s,ctrl:d("A"),alt:s,meta:s}),p({keyCode:83,keyCap:"sS",normal:s,ctrl:d("S"),alt:s,meta:s}),p({keyCode:68,keyCap:"dD",normal:s,ctrl:d("D"),alt:s,meta:s}),p({keyCode:70,keyCap:"fF",normal:s,ctrl:m(d("F")),alt:m(s),meta:s}),p({keyCode:71,keyCap:"gG",normal:s,ctrl:d("G"),alt:s,meta:s}),p({keyCode:72,keyCap:"hH",normal:m(s),ctrl:d("H"),alt:s,meta:s}),p({keyCode:74,keyCap:"jJ",normal:m(s),ctrl:d("J"),alt:s,meta:s}),p({keyCode:75,keyCap:"kK",normal:m(s),ctrl:d("K"),alt:s,meta:s}),p({keyCode:76,keyCap:"lL",normal:m(s),ctrl:d("L"),alt:s,meta:s}),p({keyCode:186,keyCap:";:",normal:s,ctrl:n,alt:s,meta:s}),p({keyCode:222,keyCap:"'\"",normal:s,ctrl:n,alt:s,meta:s}),p({keyCode:13,keyCap:"[Enter]",normal:"\r",ctrl:s,alt:s,meta:s}),p({keyCode:16,keyCap:"[Shift]",normal:l,ctrl:l,alt:l,meta:s}),p({keyCode:90,keyCap:"zZ",normal:s,ctrl:d("Z"),alt:s,meta:s}),p({keyCode:88,keyCap:"xX",normal:m(s),ctrl:m(d("X")),alt:s,meta:s}),p({keyCode:67,keyCap:"cC",normal:s,ctrl:d("C"),alt:s,meta:s}),p({keyCode:86,keyCap:"vV",normal:s,ctrl:d("V"),alt:s,meta:s}),p({keyCode:66,keyCap:"bB",normal:m(s),ctrl:m(d("B")),alt:m(s),meta:s}),p({keyCode:78,keyCap:"nN",normal:s,ctrl:m(d("N")),alt:s,meta:s}),p({keyCode:77,keyCap:"mM",normal:s,ctrl:d("M"),alt:s,meta:s}),p({keyCode:188,keyCap:",<",normal:s,ctrl:h(n,l),alt:s,meta:s}),p({keyCode:190,keyCap:".>",normal:s,ctrl:h(n,l),alt:s,meta:s}),p({keyCode:191,keyCap:"/?",normal:s,ctrl:o(d("_"),d("?")),alt:s,meta:s}),p({keyCode:17,keyCap:"[Control]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:18,keyCap:"[Alt]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:91,keyCap:"[Meta]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:32,keyCap:" ",normal:s,ctrl:d("@"),alt:s,meta:s}),p({keyCode:93,keyCap:"[Meta]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:42,keyCap:"[PRTSCR]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:145,keyCap:"[SCRLK]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:19,keyCap:"[BREAK]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:45,keyCap:"[Insert]",normal:t.CSI+"2~",ctrl:s,alt:s,meta:s}),p({keyCode:36,keyCap:"[Home]",normal:t.ESC+"OH",ctrl:s,alt:s,meta:s}),p({keyCode:33,keyCap:"[PageUp]",normal:t.CSI+"5~",ctrl:s,alt:s,meta:s}),p({keyCode:46,keyCap:"[DEL]",normal:t.CSI+"3~",ctrl:s,alt:s,meta:s}),p({keyCode:35,keyCap:"[End]",normal:t.ESC+"OF",ctrl:s,alt:s,meta:s}),p({keyCode:34,keyCap:"[PageDown]",normal:t.CSI+"6~",ctrl:s,alt:s,meta:s}),p({keyCode:38,keyCap:"[ArrowUp]",normal:m(y(t.CSI+"A",r+"A")),ctrl:s,alt:s,meta:s}),p({keyCode:40,keyCap:"[ArrowDown]",normal:m(y(t.CSI+"B",r+"B")),ctrl:s,alt:s,meta:s}),p({keyCode:39,keyCap:"[ArrowRight]",normal:m(y(t.CSI+"C",r+"C")),ctrl:s,alt:s,meta:s}),p({keyCode:37,keyCap:"[ArrowLeft]",normal:m(y(t.CSI+"D",r+"D")),ctrl:s,alt:s,meta:s}),p({keyCode:144,keyCap:"[NumLock]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:12,keyCap:"[Clear]",normal:l,ctrl:l,alt:l,meta:l}),p({keyCode:96,keyCap:"[Numpad0]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:97,keyCap:"[Numpad1]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:98,keyCap:"[Numpad2]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:99,keyCap:"[Numpad3]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:100,keyCap:"[Numpad4]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:101,keyCap:"[Numpad5]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:102,keyCap:"[Numpad6]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:103,keyCap:"[Numpad7]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:104,keyCap:"[Numpad8]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:105,keyCap:"[Numpad9]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:107,keyCap:"[NumpadAdd]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:109,keyCap:"[NumpadSubtract]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:106,keyCap:"[NumpadMultiply]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:111,keyCap:"[NumpadDivide]",normal:s,ctrl:s,alt:s,meta:s}),p({keyCode:110,keyCap:"[NumpadDicimal]",normal:s,ctrl:s,alt:s,meta:s}),this._reverseDefs.Backqoute=this._defs[192],this._reverseDefs.BracketLeft=this._defs[229],this._reverseDefs.BracketRight=this._defs[221],this._reverseDefs.Slash=this._defs[191],this._reverseDefs.Space=this._defs[32]}keyCode(e){let t=this._reverseDefs[e];return t?t.keyCode:0}key(e){let t=this._defs[e];if(!t)return"";let a=t.keyCap;return/^\[\w+\]$/.test(a)?a.substr(1,a.length-2):a.substr(0,1)}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});const o=65536,s=1<<17,l=1<<18,n=1<<19,i=1<<20;t.toUIKitFlags=function(e,t=!0){let a=0;return e.shiftKey&&(a|=s),e.ctrlKey&&(a|=l),e.altKey&&(a|=n),e.metaKey&&(a|=i),t&&(a|=o),a},t.UIKitFlagsToObject=function(e){return{shift:(e&s)==s,alt:(e&n)==n,ctrl:(e&l)==l,meta:(e&i)==i}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.default=class{constructor(){this._map={},this.expandFn=e=>{if(0===e.keys.length)return;let t=[{keyCode:121,key:"F10",code:"F10",id:"121:0"},{keyCode:112,key:"F1",code:"F1",id:"112:0"},{keyCode:113,key:"F2",code:"F2",id:"113:0"},{keyCode:114,key:"F3",code:"F3",id:"114:0"},{keyCode:115,key:"F4",code:"F4",id:"115:0"},{keyCode:116,key:"F5",code:"F5",id:"116:0"},{keyCode:117,key:"F6",code:"F6",id:"117:0"},{keyCode:118,key:"F7",code:"F7",id:"118:0"},{keyCode:119,key:"F8",code:"F8",id:"119:0"},{keyCode:120,key:"F9",code:"F9",id:"120:0"}],a=e.keys.slice();for(var o=0;o<10;o++){let s=o+48+":0",l=t[o];e.keys=a.slice(),e.keys.push(s),e.action={type:"press",key:l,mods:0},this.expandBinding(e)}},this.expandCursor=e=>{if(0==e.keys.length)return;let t=[{keyCode:36,key:"HOME",code:"HOME",id:"36:0"},{keyCode:33,key:"PGUP",code:"PGUP",id:"33:0"},{keyCode:35,key:"END",code:"END",id:"35:0"},{keyCode:34,key:"PGDOWN",code:"PGDOWN",id:"34:0"}],a=["37:0","38:0","39:0","40:0"],o=e.keys.slice();for(var s=0;s{var t=e.keys.map(e=>e.split("-")[0]);if(0==t.length)return;var a=[t.sort()],o=0;var s=[{idLeft:"16:1",idRight:"16:2",loc:e.shiftLoc},{idLeft:"17:1",idRight:"17:2",loc:e.controlLoc},{idLeft:"18:1",idRight:"18:2",loc:e.optionLoc},{idLeft:"91:1",idRight:"93:0",loc:e.commandLoc}];for(let e of s)for(o=a.length-1;o>=0;o--){var l=a[o];let t=l.indexOf(e.idLeft);if(t<0&&(t=l.indexOf(e.idRight)),t<0)continue;if(1==e.loc){l[t]=e.idLeft;continue}if(2==e.loc){l[t]=e.idRight;continue}l[t]=e.idLeft;let s=l.slice();s[t]=e.idRight,a.push(s)}for(let t of a){let a=t.sort().join(":");this._map[a]=e.action}}}reset(){this._map={}}match(e){let t=e.sort().join(":");return this._map[t]}}}]);
\ No newline at end of file
diff --git a/KB/JS/src/Keyboard.ts b/KB/JS/src/Keyboard.ts
index e6fde99ab..6013a220a 100644
--- a/KB/JS/src/Keyboard.ts
+++ b/KB/JS/src/Keyboard.ts
@@ -178,6 +178,7 @@ export default class Keyboard implements IKeyboard {
_lang: string = 'en';
_langWithDeletes = false;
+ _isHKB = false;
hasSelection: boolean = false;
@@ -522,6 +523,13 @@ export default class Keyboard implements IKeyboard {
return;
}
+ if (!this._isHKB) {
+ // Some software KBs doesn't report shift presses (GBoard for instance)
+ this._output(key);
+ _blockEvent(e);
+ return;
+ }
+
// TODO: may be remove accents only after options key is pressed.
let out = this._removeAccents ? _removeAccents(key) : key;
this._removeAccents = false;
@@ -685,11 +693,14 @@ export default class Keyboard implements IKeyboard {
}
// Keyboard language change
- _handleLang(lang: string) {
- this._lang = lang;
- this._langWithDeletes = lang === 'ko-KR';
+ _handleLang(langAndKB: string) {
+ let parts = langAndKB.split(':');
+ this._lang = parts[0];
+ this._isHKB = parts[1] === 'hw';
+
+ this._langWithDeletes = this._lang === 'ko-KR';
this._stateReset(this.hasSelection);
- if (lang != 'dictation') {
+ if (this._lang !== 'dictation') {
op('voice', {data: ''});
}
}
diff --git a/KB/Native/Views/KBWebViewBase.h b/KB/Native/Views/KBWebViewBase.h
index aacbe0ad4..17678a8ef 100644
--- a/KB/Native/Views/KBWebViewBase.h
+++ b/KB/Native/Views/KBWebViewBase.h
@@ -39,7 +39,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) UIKeyModifierFlags trackingModifierFlags;
- (void)reportStateReset:(BOOL)hasSelection;
-- (void)reportLang:(NSString *) lang;
+- (void)reportLang:(NSString *) lang isHardwareKB: (BOOL)isHardwareKB;
- (void)reportHex:(NSString *) hex;
- (void)reportPress:(UIKeyModifierFlags)mods keyId:(NSString *)keyId;
- (void)reportToolbarPress:(UIKeyModifierFlags)mods keyId:(NSString *)keyId;
diff --git a/KB/Native/Views/KBWebViewBase.m b/KB/Native/Views/KBWebViewBase.m
index a5ffb7747..67eeebb9a 100644
--- a/KB/Native/Views/KBWebViewBase.m
+++ b/KB/Native/Views/KBWebViewBase.m
@@ -144,8 +144,8 @@ - (void)setHasSelection:(BOOL)value {
[self report:@"selection" arg:value ? @"true" : @"false"];
}
-- (void)reportLang:(NSString *) lang {
- [self report:@"lang" arg:[NSString stringWithFormat:@"\"%@\"", lang]];
+- (void)reportLang:(NSString *) lang isHardwareKB: (BOOL)isHardwareKB; {
+ [self report:@"lang" arg:[NSString stringWithFormat:@"\"%@:%@\"", lang, isHardwareKB ? @"hw" : @"sw"]];
}
- (void)_keyDown:(KeyCommand *)cmd {