Is it possible to make lua "press" a key for you (gmod)?

Hello facepunch.
Was just wondering if it was possible to make lua press a key for you.
What I mean by that is that if something happens (say, you run a console command), then it will press the K key.

What does the K key do?

That’s just an example. I want to make a script that clicks a button, not a script that runs a command assigned to a button.

Also, clever avatar.

What is the purpose of clicking the button?

mayhaps this would help?


Instead of clicking this “button” just call the command directly that the button does.
Dont see why you would mimic a key press, when you can just DO what that key was supposed to do.

Is there any way to do this with numbers and letters, not just IN_KEYs?

you can use concommand?

Entity(1):ConCommand("+attack") is basically emulating the primary attack button on the player.

you can use timers and such to run Entity(1):ConCommand("-attack") which will emulate stopping the primary attack