- Home /
Is it possible to change keyboard input inGame
So im working on my menus and im wondering if its possible to change the keyboard input ingame or is it only possible in the launcher, tried looking through other answers but they were from years back and denying that such a thing was possible, so is it still not possible?
I think the goal of your question is definately possible, just not in the way your thinking. (at least to my knowledge) the only way of changing the keyboard input is through the project settings that cant be chagned in game. But you could change what the keys do through code like this switch (case) case 1: if(Input.GetButtonDown("fire1")){ // do something } break; case 2: if (Input.GetButtonDown("fire1")){ //do something else } break; Does that make sense?
Its definitely possible, but you won't be using the Input$$anonymous$$anager page Unity provides. its kinda of a pain, you have to reconstruct the whole input system.
One way is used a key based event system. basically each key you allow to be used fires a event based on its key code. you assign a command (e.g Accept) to receive a key code event. whenever your key code event is fired it will invoke your command event (that is like your fire button) which your Interface or game will receive then it will process that input.
$$anonymous$$aking an in-game interface that does this can be tricky, you will want to have your game planned out a little bit so that you know what commandEvents you want.
Answer by _Gkxd · Jul 05, 2015 at 07:07 AM
Rather than changing the input system itself which can get complicated, you can create variables that hold key values that you can change later. Take the following example:
// Inside Update
if (Input.KeyPressed(KeyCode.Z)) {
// Attack
}
You can instead store the key code in a variable that you can change later:
// Where you declare variables
public KeyCode attackKey = KeyCode.z; // You can change this at any time
// Inside Update()
if (Input.KeyPressed(attackKey)) {
// Attack
}
This effectively lets you change around key settings.
Your answer
Follow this Question
Related Questions
Key not recognized 2 Answers
problem whit input key 2 Answers
Input system looses keypress after a few frames [BUG?] 0 Answers
Mobile Keyboard hide on tap screen. 2 Answers
Press GUI button with key press 1 Answer