- Home /
The question is answered, right answer was accepted
Is there a way to prevent UI buttons from being triggered by keyboard inputs?
Is there a way to prevent unity UI buttons from being triggered by any keyboard input? I only want them to respond to mouse inputs as keypresses are handled through code due to.... reasons. Is there a way to do this with the inbuilt ui system or am I going to have to do some sort of raycast in trickery and have no onclick in my button?
Answer by FlaSh-G · May 09, 2020 at 06:42 AM
What triggers the "Submit" is the event system. The two components on that GameObject that is automatically created are the EventSystem componnent and the InputModule. The latter of these is sending Navigation, Submit and Cancel events to the event system. By fiddling with the inputs set up in the Standalone Input Module, you can disable submission by keyboard inputs - in the long run, it's also an idea to write a custom input module.
Thanks for the response. I did try fiddling with the input module but it started throwing errors when I had things unassigned which I didn't like. I actually got around it all by going into the project settings and completely stripping out any keyboard based navigation in there which worked a treat. I appreciate you taking the time to respond, I should have closed this question but forgot.
Follow this Question
Related Questions
Issue with spawning buttons and assigning listeners 1 Answer
How can I use OnMouseDown and a button click in the same scene? 0 Answers
How can I add function to onClick event by code? 2 Answers
Add different input for On Click event (UI) 0 Answers
Cannot click on a button while Drag Events are called 2 Answers