Hi!, is there a way to know any key that an user has pressed?
like a scanf :S
thanks for any help!
Hi!, is there a way to know any key that an user has pressed?
like a scanf :S
thanks for any help!
Input.inputString
Daniel, thanks.
I think I was wrong, and Iâll ask the question better
I need is to capture the keycodes of any key pressed.
For example if i press Button 0 on any joystick then I need to get JoystickButton0
Again, sorry for asking a wrong question :S
The unity input model works reversed of what youâre hinting at. Check out
file:///Applications/Unity/Documentation/ScriptReference/Input.html
for reference. Usually in a game you know which key youâre looking for, so youâd do that by running GetButton / GetButtonUp / GetButtonDown checks. Perhaps if you explain what it is youâre trying to do, we could be of further assistance?
if (Input.anyKeyDown)
{
keyPressed = Input.inputString;
}
Is that what you are looking for?
-Jeremy
Heâs trying to code a key bindings screen, thereâs not game config screen for webplayer builds so we need to script one ourselves to allow players to change their input configuration.
Getting the keycode is the easy part of the problem, but after we find the key the user pressed how do we assign it to the InputManager? Canât find anything about this is the docs.
Kind of that Jeremy, But, if i press for example F1, keyPressed will be filled with ââ.
On the other hand, Angryhat.
Iâm trying to make my own custom Input manager, so we dont need to use the Input window to bind the custom keys that all the unity apps have when you start them.
If Iâm not clearly enough please tell me and iâll try to explain myself better.
I speak Spanish! srry for my bad english
Ah ok, I didnât read your post carefully enough either.
There is no nice built-in way to do this, so you would have to check for every possible button I am afraid.
Might be worth wish listing this.
EDIT: Also, to bind input controls from your own interface, you basically have to write your own input manager and forget Unityâs altogether, as Unityâs input manager doesnât currently support messing with the settings from code.
-Jeremy
Jeremy, that was that i was thinking iâll have to doâŚ
Currently Iâm writing one at the moment.
thanks for the help!
If you want, i did the hard work for youâŚ
http://forum.unity3d.com/viewtopic.php?t=57501&postdays=0&postorder=asc&start=0
A custom inputmanager, easy to use cheers
Iâd think the need for this has probably dissipated some. Especially considering that the last post before yours was some two years ago. You think Iâm on to something here?
Unless Iâm missing something, I donât necessarily agree that thereâs no interest in something like this. In-game, on-the-fly custom keybindings are pretty important, even expected, these days. It just doesnât cut it to have to exit/restart a game just to rebind some controls youâre not really feeling.
Hunting through the scripting reference, I do see a couple of things like Event.character, but I canât for the life of me figure out how to access them properly, since theyâre barely documented.
event = Event.current;
if(event.isKey){
if(event.type == EventType.KeyDown){
Debug.Log(event.keyCode);
}
}
look at Event class
look at EventType class
look at KeyCode class
you have urself a an Event based thing
this is to be done inside an OnGUI call.
(This is the only way to access input data during an Editor script as well)
Cheers! I tried a number of different permutations of those calls within OnGUI, but never quite managed to find the right one.
sorry i revived a old post,i didnt checked dateâŚ
But if you want to find out how i did it, you can download my inputmanager and check the source, its free anywayâŚ