How would I go around making F4 act as a chat command on my server?

Basically, I wan’t it so that when people press F4 it would display the MOTD(Which is currently done by typing !motd) & another F key will let a user switch teams.

Currently, a user has to type !swap to switch to guards/prisoners.

I am not sure of the code that would work this.

So overall it would be something like

User presses F4
It acts as typing !motd in chat
MOTD appears


User presses F4
It acts as if user typed !swap
swap list appears

Use these functions.

GM:ShowHelp --F1
GM:ShowTeam --F2
GM:ShowSpare1 --F3
GM:ShowSpare2 --F4

This will print the player who pressed F1 everytime they press it.

function GM:ShowHelp( ply ) 
    print( ply.. "pressed F1" )

You can also hook it like this:
ply:ConCommand(“say !swap”)

This will make the player say !swap when you press F4, if you wanted motd just replace the !swap with !motd.

What there controls which F key makes it say !swap?

ShowSpare2 = F4 and the function that goosey wrote hooks into ShowSpare2. That means that it will check to see if the person is pressing F4 before it runs the function. You can use the chart that Jarva posted and change it to any of the other F buttons.

Thank you very much guys, I really appreciate your help.