copy / v86

x86 PC emulator and x86-to-wasm JIT, running in the browser
https://copy.sh/v86/
BSD 2-Clause "Simplified" License
19.65k stars 1.38k forks source link

non-QWERTY keyboards have incorrect input #1031

Open Ponali opened 5 months ago

Ponali commented 5 months ago

hi, my keyboard is in AZERTY, which is the normal type of keyboard for my country, but that causes some problems with input. keys like "," turn into "m" and vice-versa, "a" turns into "q" and vice-versa. with my DOM JS experience, this could be an issue with the keyboard script(s) because it tries to get a QWERTY-reliant value, which doesn't happen with "key" and the deprecated "keyCode". this is just some of my speculation however.

SuperMaxusa commented 5 months ago

395 and https://github.com/copy/v86/issues/831#issuecomment-1498688296

it tries to get a QWERTY-reliant value, which doesn't happen with "key" and the deprecated "keyCode".

v86 uses event.code, that uses standard QWERTY physical keys layout and not depends by host keyboard layout (https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code#handle_keyboard_events_in_a_game), and convert to BIOS key codes. https://github.com/copy/v86/blob/c69cbd7854d7cbda08679c389973aa87c9fb37bd/src/browser/keyboard.js#L316 https://github.com/copy/v86/blob/c69cbd7854d7cbda08679c389973aa87c9fb37bd/src/browser/keyboard.js#L122-L126

Workaround is setting on guest OS needed for you layout (for example, via loadkeys, demo: https://copy.sh/v86?profile=archlinux&c=loadkeys%20fr)