- Home /
Activate GUI Button with Enter Key
Right now, I can successfully change the focused button on my in-game pause menu by pressing up and down. However, I'm stumped as to how to implement a way to select that focused button via keyboard button press (The only way I can actually activate the button is clicking on it with the mouse). What is the best way to go about doing this?
Answer by DaveA · Aug 25, 2012 at 02:08 AM
If you know which button is focused at any time, you can look at Input.GetKeyDown(KeyCode.Enter) and activate whatever it would do.
Alrighty. I was hoping there was something simple along the lines of "set the currently targeted control's value to true" or whatever, but I went about accomplishing what I needed to do by storing the name of the currently targeted control and using that in my input check.
Your answer
![](https://koobas.hobune.stream/wayback/20220613080137im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Is there a way to combine the Update and OnGUI functions? 1 Answer
On Screen Keyboard (PC and Console) best practices 3 Answers
Text Prompt Problem 1 Answer
Determining GUI button pressed 2 Answers
gui list problem 2 Answers