Sign in to follow this  

Custom keybinds/name input?

Recommended Posts

Hi there
I've googled this topic for a bit but didn't come up with a good solution yet so I thought I might bring this up here:
Is there a way to write custom keybinds for an options menu (e.g. there is an entry for "Up" in the game and you can then rebind it for whatever key you like: w, t, up, enter etc...). I guess the menu has to check every single key for whether it was pressed during the rebind? (also I'd like to then save each individual bind to a config file but I'm going to read up on how to do that myself ;) ).

The same basically goes for entering a name, right? I mean, it also has to check every key and write the associated letter :S

I've seen people do that by writing out every Key, but I guess thats no graceful solution?

Sorry for posting this ^^ I didn't know there was already a thread on this here -.- Edited by fuerchter

Share this post

Link to post
Share on other sites
The key is to [b]define a list of actions [/b]that is needed by your game: up, down, left, right, jump, fire, etc.. and store on these actions the key selected:
Keys up, down, left, right, jump, fire;

Now when you enter your option menu to configure "jump" action (for example) you need to listen for keyboard pressed keys and, when is pressed [b]only one key[/b], you can store jump binding like this:
jump = Keyboard.GetState().GetPressedKeys()[0];

You need to take care to [b]wait the release[/b] of the key used in the option menu to enter the "key selection mode" (if you use Enter you need to wait for Enter release to avoid to bind jump to enter key).

This link can help you (but I don't know your programming level):

Check also this link, is usefull for GamePad/Mouse/Keyboard input design:

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this