bracket-lib icon indicating copy to clipboard operation
bracket-lib copied to clipboard

Keyboard layout not working for wasm target

Open joncol opened this issue 3 years ago • 5 comments

I'm trying to pick up some basics of wasm, by following along with the Roguelike tutorial.

I ran into a weird issue when trying to get movement to work using hjkl (instead of the arrow keys). The issue is that I use a Colemak layout (via setxkbmap on Linux) so these keys are not in their original positions. The keys work as I expect when running locally through cargo run, but when running via a local web server and the wasm32-unknown-unknown target, the Colemak layout is somehow disabled and the keys are in their QWERTY positions.

Any idea where I can start looking for a solution to this? I was expecting the Colemak layout to work in my wasm projects as in the rest of my system. Maybe the problem lies at a lower level than bracket-lib?

(The full setxkbmap command I use is: setxkbmap -model pc105 -layout us,us -variant colemak,altgr-intl -option -option "grp:shifts_toggle,ctrl:nocaps,terminate:ctrl_alt_bksp")

Thanks for the nice library and tutorial!

joncol avatar Nov 29 '20 17:11 joncol

Bracket-lib wasm input works by specifying HTML key codes.

Zireael07 avatar Nov 29 '20 18:11 Zireael07

Bracket-lib wasm input works by specifying HTML key codes.

So how can I make wasm input respect my system layout? I tried with INPUT.lock() and is_scancode_pressed, and that works fine locally, but not for wasm target.

joncol avatar Nov 29 '20 18:11 joncol

Currently, that's going to be a problem - it picks up scan codes, so it doesn't know about your locale properly. I'll mark this as an enhancement, and try to get it working on a release after the current one (which focuses on fixing Mac issues).

thebracket avatar Feb 11 '21 17:02 thebracket

Cool, I suspect the problem is on a lower layer, if you're using some other library for keyboard handling. I've experienced the same in other WebAssembly situations.

(which focuses on fixing Mac issues)

Just FYI, the Colemak keyboard layout is not related to Mac :). It's an alternative to Qwerty and Dvorak.

joncol avatar Feb 11 '21 18:02 joncol

Sorry, I was unclear -the CURRENT push is Mac issues. I'll get to keyboards after that.

thebracket avatar Feb 11 '21 18:02 thebracket