Activate button using keyboard for a given time

How to make a button show as activated(pushed) for a given time when triggering it with the keyboard? How to activate a button using the keyboard?

(Currently I assign an ID to every control and when a key is pressed I simply handle it using the Input class and based on which ID is the active control I call the method I call when I click the button. ---So this is just a "hacked" keyboard support for my GUI and the above mentioned IDs have nothing to do with the GUIUtility stuff--- I haven't tried the GUIUtility class so far because of the lack of documentation(of course I could figure it out by trying))

I could set the button's style to one with normal GUIStyleState matches the originals active GUIStyleState and change it back when I want to maybe with an Invoke but this seems rather cumbersome.

So I added keyboard&mouse controllability to my GUI by detecting which control the mouse is hovering for myself using mousePosition and Rect.Contains().

My buttons style are so that they have a normal and an active state. When you click a button it automatically changes to it's active state.

That was ok but since I wanted keyboard support too I encountered a small problem that I have to manually change the button's style's state. I couldn't do that so I went with the following.

I have 2 GUIStyles, 1 normal whose normal state is the normal and whose active is the active & an other whose normal is the active state. When the user presses the button using my hacked keyboard support I simply change the buttons style to the 2nd and Invoke a method with a delay to reset it back.

(I just realized that I may have misinterpreted your question, sorry).

Strongly recommend learning the Input Manager, as this is precisely what it was intended for.

The thing that got me to understand it was that every button is modelled as an "axis"... i.e. even digital button presses are considered "analogue" - it's just that their "0 to 1"ness happens at infinite speed (having sensitivity set high (around 1000) means the "axis" is fully pushed within a frame. Having Gravity set to 1000 means the axis resets to zero within a frame)

The long and short of it is, that input manager handles pretty much anything I can think of in terms of binding whatever key to whatever verb.

And if you just want direct access to stuff, there's always

Input.GetKey(KeyCode.Joystick3Button13) etc

So yes. I'd say it's well worth the time to learn this. Just type 'Input' then '.' if you have intellisense in Visual studio, and away you go. It's fairly self explanatory, and will save you time if you give it a chance!