Skip to content

Commit

Permalink
Merge pull request #162 from kou-yeung/feature/fix_#161
Browse files Browse the repository at this point in the history
fix #161 : autocomplete was post event to keydown.
  • Loading branch information
kou-yeung authored Jun 29, 2024
2 parents fd6a006 + 2e58686 commit 7d13f3e
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 7d13f3e

Please sign in to comment.