Kode / Kha

Ultra-portable, high performance, open source multimedia framework.
http://kha.tech
zlib License
1.48k stars 171 forks source link

Access to native js events #1472

Closed RblSb closed 10 months ago

RblSb commented 10 months ago

I use this to update state of shift/alt/ctrl keys in my user code keys map, when clicking canvas, because keys is not always updated in keydown/up. For example, if you open console with shift-ctrl-i, modifiers will stuck as pressed. Usage example:

#if kha_html5
final e = SystemImpl.activeMouseEvent ?? return;
// when keyup happens with unfocused window
keys.set(Shift, e.shiftKey);
keys.set(Control, e.ctrlKey);
keys.set(Alt, e.altKey);
keys.set(Meta, e.metaKey);
#end
// ... handle Alt + Click, etc