Keybinding issues (when remapping keys in OS)
Posted: Thu Feb 28, 2019 12:41 pm
tl;dr
"I updated from 0.16 and keybindings are all messed up."
- What keyboard layout do you use? Go to Control options in the game and reset to default.
"The game doesn't seem to detect some keys.", "The control settings change after restart."
- Sounds like bugs.
"I remapped keys in OS and the game does not respect that."
- It's a bug if the issue is when typing text. Re-mapping modifier keys for in-game shortucts needs to be solved by us. Other cases mostly are not bug, you need to rebind keys in control settings to whatever you like.
---------------------------
There are lot of report regarding to different keybinding issues. So I'd like to address them here in general to reduce number of duplicate threads.
The differences between 0.16 and 0.17 come from migration from Allegro to SDL2, which introduced some bugs; at the same time we switched from handling keys by their keycode (which represents "meaning" of keys) to their scancode (which identifies positions of keys on keyboard). See: FFF #259
For the most part, we are designing default control bindings around positions of key and not their meaning. If player movement is supposed to be controlled by WASD, we mean very specific keys not necessarily keys that produce letters W, A, S or D. For example on French AZERTY keyboard movement is on ZQSD, but these are physically the same keys as WASD on QWERT* keyboards.
Because before 0.17, people with keyboard layouts that diverged a log from QWERTY had to change their default control settings, these setting don't make sense anymore in 0.17, which can create issues when updating from 0.16. We have added auto-reset of 0.16 bindings when AZERTY layout is detected during startup, if there are some other widely used layouts that would benefit from auto-reset (Dvorak? Colemak?), please let me know.
So, because of using scancodes, remapping keys in your OS doesn't have any effect on the game. This is intended.
There couple of exceptions to this:
- When typing text, the game should respect your keyboard layout. So if you swap Backspace and CapsLock, it should work as it would in a text editor when your writing to chat or other text boxes.
- Shortcuts for Undo, Cut, Copy and Paste should respect your keyboard layout (to some extent) Ctrl+Z, Ctrl+X, Ctrl+C, Ctrl+V, because these shortcuts are universaly used. There is already exception to this exception, because due to conflict with other controls, we default Undo to Ctrl+W on AZERTY layout as of 0.17.2.
One could argue, that Esc is also universal shortcut ... maybe, we need to think more about this.
My point is - in-game controls are (and should be) based on positions of keys on keyboard, if they don't feel right to you, change them in control settings.
Problem is - the game won't let you use any key as a modifier key, so we need to solve that somehow. Most likely fix will be detecting modifier keys based on keycode instead of scancode.
Issues to solve:
"I updated from 0.16 and keybindings are all messed up."
- What keyboard layout do you use? Go to Control options in the game and reset to default.
"The game doesn't seem to detect some keys.", "The control settings change after restart."
- Sounds like bugs.
"I remapped keys in OS and the game does not respect that."
- It's a bug if the issue is when typing text. Re-mapping modifier keys for in-game shortucts needs to be solved by us. Other cases mostly are not bug, you need to rebind keys in control settings to whatever you like.
---------------------------
There are lot of report regarding to different keybinding issues. So I'd like to address them here in general to reduce number of duplicate threads.
The differences between 0.16 and 0.17 come from migration from Allegro to SDL2, which introduced some bugs; at the same time we switched from handling keys by their keycode (which represents "meaning" of keys) to their scancode (which identifies positions of keys on keyboard). See: FFF #259
For the most part, we are designing default control bindings around positions of key and not their meaning. If player movement is supposed to be controlled by WASD, we mean very specific keys not necessarily keys that produce letters W, A, S or D. For example on French AZERTY keyboard movement is on ZQSD, but these are physically the same keys as WASD on QWERT* keyboards.
Because before 0.17, people with keyboard layouts that diverged a log from QWERTY had to change their default control settings, these setting don't make sense anymore in 0.17, which can create issues when updating from 0.16. We have added auto-reset of 0.16 bindings when AZERTY layout is detected during startup, if there are some other widely used layouts that would benefit from auto-reset (Dvorak? Colemak?), please let me know.
So, because of using scancodes, remapping keys in your OS doesn't have any effect on the game. This is intended.
There couple of exceptions to this:
- When typing text, the game should respect your keyboard layout. So if you swap Backspace and CapsLock, it should work as it would in a text editor when your writing to chat or other text boxes.
- Shortcuts for Undo, Cut, Copy and Paste should respect your keyboard layout (to some extent) Ctrl+Z, Ctrl+X, Ctrl+C, Ctrl+V, because these shortcuts are universaly used. There is already exception to this exception, because due to conflict with other controls, we default Undo to Ctrl+W on AZERTY layout as of 0.17.2.
One could argue, that Esc is also universal shortcut ... maybe, we need to think more about this.
My point is - in-game controls are (and should be) based on positions of keys on keyboard, if they don't feel right to you, change them in control settings.
Problem is - the game won't let you use any key as a modifier key, so we need to solve that somehow. Most likely fix will be detecting modifier keys based on keycode instead of scancode.
Issues to solve:
- Handle remapped modifier keys.
- Respect OS keyboard layout when typing text.
- macOS doesn't seem to register Cmd key for some players.
- Determine if Esc should be also treated specially.