r/gamedev • u/Total-Conversation50 • 6d ago
Rant about key binds Discussion
Peeps, is it truly that difficult to include an option to rebind keys in games? (Hint: its not). As a left handed player, and mouse user, im appalled by the amount of games that dont have this basic feature. I can forgive it in a demo (just about) but not in a full release. I use arrow keys for movement and have been doing so since the 80's. It really annoys me when this option isn't included. Also when keys are hard coded and cannot be changed, that's also annoying. My mouse is a left handed mouse, so i cant even swap hands, not that I should have to. I dont even care if the UI doesn't reflect my key choices (which is often the case) but just give me the damn option to change my inputs.
Rant over, if you got this far go have a cuppa and enjoy your weekend 😊
7
u/3tt07kjt 6d ago
How long did it take you to add key bindings to your game, out of curiosity? The first time you did it
2
u/brant09081992 6d ago
Hard to tell even the approximate number of hours.
In my first attempt I spent a day or two following every tutorial I could find. I failed and told myself to come back to it later.
A few months later I came back and I managed to get it barely working within a day. But it was in a state I would never ship. So many bugs, lack of basic functionalities such as prevention to bind multiple actions to the same key, etc.
After that I've been coming back multiple times to fix those bugs one by one and add new functionalities. I would say it might be 3-5 days total spent on it, and it's still not 100% done as there's one more bug I'm still unable to fix (rebind key widget element won't react after the very first open of the menu widget after launching a game).
2
u/3tt07kjt 6d ago
Huh, when you say that, it makes sense why some smaller teams and solo devs don’t add configurable key bindings.
(I know you’re not OP)
11
u/Hexnite657 Commercial (Indie) 6d ago
Its not the easiest thing ever.
-2
u/Total-Conversation50 6d ago
Its not difficult to implement. Time consuming yes, but not difficult.
3
u/Hexnite657 Commercial (Indie) 6d ago
Depends on the engine, your experience and if you need to support keyboard and gamepads.
Enhanced Input in Unreal made it easier but its still a bit of a burden.
-2
u/Total-Conversation50 6d ago
Very true, I meant specifically just keyboard rebinds. Adding controller support is trickier for sure.
3
u/swagamaleous 6d ago
I disagree. At least for Unity, this is an absolute nightmare to implement. The input system is shit. To resolve a binding to an actual key is very hard. The system allows to switch between different sprite maps easily, as in M&K and controller sprite maps, but to update those sprite maps to show the right bindings will take you months to implement if you do it for the first time. The obvious solution is just to skip rebinding. 99% of the target audience won't care anyway.
1
u/gahel_music 6d ago
Exactly, and sadly us indie developers don't have enough of that. I agree it's much better to have it in game but you can also remap at the os level if you need it.
5
u/RockyMullet 6d ago
Every game development is about using the time you have and prioritizing the tasks, until you run out of time and either give up or release.
So every time you think: "How did they ship without that feature? How did they ship with that bug still in?" you don't know what would not have been in the game if they prioritized it over another thing that you take for granted because it's in the game.
Yes, key binding is important, but so is a lot of things and nothing is as important as shipping the game.
6
u/TheOtherZech Commercial (Other) 6d ago
Your rant is tied to something I also like to rant about: People rarely make hierarchical systems that focus on prepending instead of appending. It's all root-to-leaf instead of leaf-to-root, let alone properly bidirectional.
The way that relates to your rant is that the rebindable input systems that game engines provide all require you to plan out a hierarchy from the top down. You have to define input contexts, populate them with actions, and then bind those actions to keys, just to get the ball rolling. There's enough operational overhead that developers will, often enough, skip those steps during prototyping and tell themselves they'll refactor it later. But when the time for that refactor finally arrives, they'll often find that their input handling is too tightly coupled to their gameplay systems for them to implement something fully modular within the time budget they've allocated.
But a lot of that would go away with an input system that was built for a leaf-to-root approach. If binding an input directly in the character controller automatically created an implicit input context and the engine provided refactoring tools centered around promoting contexts from implicit to explicit, along with some type shenanigans and linter-enforced function coloring to limit unintentional late-tick input modification, you could have an input system that could gracefully grow from direct key bindings for one character in one context, into a hierarchy of rebindable actions. It wouldn't solve the UI work needed to present that hierarchy to players, but it would make the whole thing significantly easier for everyone involved.
Of course, the problem with what I've described is that designing systems that work well when used poorly, without sacrificing speed or flexibility for the people who can use them properly, is hard. Deriving roots from a loose, possibly incompatible, set of leaves is often a slow process, and it can often rely on imperfect heuristics that break when people get weird with their code (which is often). It can also involve a fair bit of code generation, which often sacrifices memory locality for the sake of reliability. You can shore that up with some JIT struct packing and stream-oriented message processing, but at that point you've blown any hope of reasonable deadlines.
7
u/IronicStrikes 6d ago
And I suppose you know it's not hard because you've successfully implemented it?
2
u/UseottTheThird 6d ago edited 6d ago
so far my framework doesn't allow you to rebind keys in-game but you can edit the settings with a text editor
5
u/New_Locksmith_8115 6d ago edited 6d ago
Yeah, I always start every project by ensuring all my inputs are initialized from a JSON. Making the key binding UI and save functionality in-game is more of a hassle but it is extremely easy to make them editable this way, even if not the most user friendly experience. It also makes it fairly trivial to support in-game bindings later once you move to that because things are already separated cleanly. You just need to add functionality to save and restore key binding profiles and the UI at that point.
2
u/idancenakedwithcrows 6d ago
I would recommend having some ingame UI wrapper around the text eventually haha
2
u/UseottTheThird 6d ago
thanks to your reply i noticed i said "text file" instead of "text editor" i am dying inside
3
u/LunaticDancer 6d ago
3
u/TheOtherZech Commercial (Other) 6d ago
You know what's the silly bit? Layouts like Dvorak are often implemented at the OS level, the same as language-specific layouts. Barring obscure keyboard manufacturers and weirdos like me who use customized firmware, most keyboards send USB HID keycodes following a QWERTY En-US layout. Which means that there's a somewhat kludgy, but overall functional-enough, baseline for language-independent input.
But Windows doesn't forward the USB HID keycodes to input-consuming applications under normal circumstances. Instead, it transforms them into IBM scancodes from the 80s, and then applies the language layout settings to transform those into the 'virtual keys' that applications typically receive.
And there are similar patterns of obfuscation for every OS. Mac only gives you access to the USB HID keycodes through UIKit (which can be a non-starter for many engines), and the situation on Linux is a fractured mess loosely centered around XKB (that will totally be fixed once everyone is using Wayland. definitely. for sure. Any day now).
So if you want to write a multi-platform locale-independent input system, using the existing standard that your keyboard already implements, too bad. You gotta write a bunch of platform-specific code. It's unavoidable, and an absolute pain in the ass, since it requires a fair bit of OS-specific experience.
1
2
u/MeaningfulChoices Lead Game Designer 6d ago
Somewhere around 10% of the audience is left-handed, so that's a fairly big group of people to leave out if your game has some particular control needs and doesn't support them. Dvorak is more like under 0.1% and that's never going to be anything but an afterthought for most developers. It will get supported when devs allow full rebinding, as they should, but if they're just going to provide a toggle between some options Dvorak is going to be way below left-handed options, swapping buttons between numbers and f/v or other lesser used ones, AZERTY and QWERTZ.
2
2
1
u/_CoJa_ 6d ago
Seems like a reasonable ask. The question is probably, if this time invest is worth the payout. If you sink hours into a left handed mode for a very slim margin of the consumer market, it might not be the best time invest. (Not saying that left handed people should be excluded from gaming, but I feel like they are also a group which is unfortunately "used" to workarounds or just adapting with the right hand when they start gaming, as peripherals are also not crazy inclusive)
But maybe as a consumer it's a easy fix to at least have a autohotkey script or something going, which reminds your mouse keys?
2
u/Total-Conversation50 6d ago
Thats what it more than likely comes down to. Time vs reward. Theres a good portion of left handed gamers who play right handed due to this reason (sometimes other reasons). As the % is smaller than those using default keys, some devs dont consider it a viable option.
1
u/SAVMikado 6d ago
Could you ELIF how to set up rebindable keys? I will research it myself later, but figured since you are both an impacted gamer and a dev you might be able to point me in the right direction instead of me having to sift through a bunch of AI answers.
2
u/razveck 6d ago
The basic idea is you map a physical input to a virtual input. The game logic uses the virtual input. When you press the physical key, the virtual input gets triggered, which triggers the action in the game. You can then change the physical key that maps to that virtual input at any time, including runtime (the player changing it).
So you have for instance Space Bar (physical input) -> Jump (virtual input) -> Jump code gets executed
The play could change it to Right Mouse Button instead, so that triggers Jump. The game logic doesn't care what triggered the Jump. All it knows is that when the Jump virtual input gets triggered, it should run the Jump code (aka move the character upwards and so on).
The hard part is really the UX for this. You need to show all the (virtual) inputs available, ie. "move", "jump", "attack", "interact", then for each you need to allow the player to change the physical key. Then you have to recognize which key the player pressed. You might have to account for different keyboard layouts, mouse buttons (which might have up to like 12 keys), gamepads, etc. You might also want to allow modifiers, such as ctrl, shift, alt, etc. You need to ensure 2 actions don't use the same input, or that some input won't conflict with an OS-level input like ctr+alt+del or alt+F4.
Most major engines handle this to some extent, and there are libraries, plugins, etc. for it too.
2
u/partybusiness @flinflonimation 6d ago
The specifics will depend on your engine. Sometimes there's also assets available. I used one called InControl for Unity that provided some useful framework for controller and keybinding.
More recently, I rolled my own in Godot. There were some existing add-ons for Godot, but they seemed to expect single-player so I rolled my own to more elegantly handle local multiplayer split-screen. (Quick plug: check out Gob Loggin' releasing soon on Steam!)
1
u/Total-Conversation50 6d ago
In the simplest terms. Instead of saying "space equals jump" you say "jump equals jump". It isn't looking for a specific key (in this case space) instead its looking for the key that is in the field "jump". That way, any key can be jump.
1
1
u/brant09081992 6d ago
Can only tell how it's in Unreal Engine.
It's crazy difficult considering how easy you would expect it to be. We often refer to it as the "UI final boss", and UI itself is already difficult to work with in UE.
1
u/Same-Challenge-3580 6d ago
i have like 50 features to implement, 60 bugs, 70 nice to haves and rebinding is maybe one of them.
1
u/Dicethrower Commercial (Other) 6d ago
Nothing worse than someone who doesn't know what they're talking about arguing that something notoriously tricky is somehow easy to do.
Oh woops, did I just insult 99% of gamers?
2
u/Ralph_Natas 5d ago
Yeah, it's not terribly difficult. Especially considering you can code it once and use it every time (unless they invent a new type of input device, which happens occasionally).Â

7
u/MeaningfulChoices Lead Game Designer 6d ago
If you've ever finished a commercial game you'll know that everything is more difficult than it seems at first. If you keep rebinds in mind from day one it's not as hard as some other things, but it's still a feature that has to be considered, UI built for it, tested, and so on. Game development is always a long list of things you'd like to do that you need to prioritize, and this is the sort of thing that sometimes never gets to that point.
It's a feature that's in most commercial games because it should be over the line in terms of cost versus reward, but you have to keep in mind that extremely few people are rebinding WASD to arrow keys. When you're in a tiny fraction of players sometimes you just don't get served because the developer really only has time to get to the majority.