- Home /
NGUI/GUI button emulating Keyboard letter press
Hiya,
Just wondering if it's possible to get a NGUI/GUI button to emulate a letter on a keyboard as there is an asset that i'm using that using keyboard controls to select targets and since the game is for mobile, I don't really want the keyboard on screen as it will take up too much room.
i.e if i press a button (SelectNextTarget) I want it to be able to select the letter t (Keycode = KeyCode.T) which would select the next target.
I know I can bind a button to a key so that the key selects the button, but I would like it to go in reverse....
A little vague...could you explain a bit more please?
What is specific about the letter T? Can you do something like
if(GUI.Button(buttonDims_for_SelectNextTarget)) {
// call SelectNextTarget function that used to be called when someone pushed the letter "T"
}
I figured out where i was going wrong, seems you cant bind a button to a keyboard letter, but the asset i used sent the key bindings to another script which had the functions i was trying to use
@Supershandy: You could use the SendInput function to send/emulate any kind of input (mouse or keyboard), msdn, stackoverflow. It's a bit cumbersome and windows-only as I mentioned before. But I managed to successfully get it to work, for example. If you want to go this way, let me know, I think I have the code somewhere for sending keyboard keys.
Answer by unimechanic · Feb 22, 2014 at 01:50 AM
Question solved according to comments:
figured out where i was going wrong, seems you cant bind a button to a keyboard letter, but the asset i used sent the key bindings to another script which had the functions i was trying to use*
[Adding this answer to remove it from the Unanswered list.]
Surely it's preferable to convert the comment and mark it answered. While I realise that this will award $$anonymous$$arma to the questioner, it would seem better in this case to have it marked correct.
Your answer
![](https://koobas.hobune.stream/wayback/20220613133705im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Use Unity UI For 2D Games Or Custom Objects Instead? 2 Answers
In-game text editor, native or NGUI 2 Answers
Cropped Label Problem - Big Font - Unity3D 1 Answer
How to see NGUI in SceneView 1 Answer
Is unity gui good to use 2 Answers