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?

[lua]
function KeyPressed (ply, key)
if key == 25 then
ply:ConCommand(“kill”)
end
end

hook.Add( “KeyPress”, “KeyPressedHook”, KeyPressed )
[/lua]

Kills the player when they press O

thank you

[editline]11:25PM[/editline]

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

Of course.