Running A Console Command By Pressing a key via LUA

How can I do this? How can I run a console command by pressing a key via LUA?

function KeyPressed (ply, key)
if key == 25 then

hook.Add( “KeyPress”, “KeyPressedHook”, KeyPressed )

Kills the player when they press O

thank you


well, I made my own console command (gamemode purposes), so will it work with custom made ones?

Of course.