Skip to content

Commit

Permalink
fix #161 : autocomplete was post event to keydown.
Browse files Browse the repository at this point in the history
  • Loading branch information
kou-yeung committed Jun 29, 2024
1 parent fd6a006 commit 2e58686
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Assets/WebGLSupport/WebGLInput/WebGLInput.jslib
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,16 @@ var WebGLInput = {
WebGLInputOnKeyboardEvent:function(id, cb){
var input = instances[id];
var func = function(mode, e) {
var bufferSize = lengthBytesUTF8(e.key) + 1;
var key = _malloc(bufferSize);
stringToUTF8(e.key, key, bufferSize);
var code = e.code;
var shift = e.shiftKey ? 1 : 0;
var ctrl = e.ctrlKey ? 1 : 0;
var alt = e.altKey ? 1 : 0;
(!!Runtime.dynCall) ? Runtime.dynCall("viiiiiii", cb, [id, mode, key, code, shift, ctrl, alt]) : {{{ makeDynCall("viiiiiii", "cb") }}}(id, mode, key, code, shift, ctrl, alt);
if (e instanceof KeyboardEvent){
var bufferSize = lengthBytesUTF8(e.key) + 1;
var key = _malloc(bufferSize);
stringToUTF8(e.key, key, bufferSize);
var code = e.code;
var shift = e.shiftKey ? 1 : 0;
var ctrl = e.ctrlKey ? 1 : 0;
var alt = e.altKey ? 1 : 0;
(!!Runtime.dynCall) ? Runtime.dynCall("viiiiiii", cb, [id, mode, key, code, shift, ctrl, alt]) : {{{ makeDynCall("viiiiiii", "cb") }}}(id, mode, key, code, shift, ctrl, alt);
}
}
input.addEventListener('keydown', function(e) { func(1, e); });
input.addEventListener('keyup', function(e) { func(2, e); });
Expand Down

0 comments on commit 2e58686

Please sign in to comment.