Assigning the key for a derma menu

Ok, So I’ve made a Derma menu that drops down a website. To get it down you have to use a console command, but I need the menu to be at F4 at default for every player that joins my server.

How do I do that? I’ve read through every guide on wiki.garrysmod but I can’t find out how to make the menu drop down by pressing F4, without binding anything.


**[Gamemode.ShowSpare2](** hook to this and run the console command.

For F1-F4 you can use gamemode hooks (**[Gamemode.ShowHelp](** (F1), **[Gamemode.ShowTeam](** (F2), **[Gamemode.ShowSpare1](** (F3) and **[Gamemode.ShowSpare2](** (F4)). Hook to one of these, and send a usermessage which will tell the client to open the Derma Menu.

Thanks guys!
Is it possible to bind it any other button, like “Home” or “F5”?

Yes, with a think hook and input.IsKeyDown:

[lua]hook.Add( “Think”, “MenuKeyListener”, function()
if ( input.IsKeyDown( KEY_F5 ) and !menuOpen ) then
end )[/lua]


I don’t that would work, because if you scroll down on THIS to the bit where it has all of the red functions you cannot run them
Then as you’ll see one of the non useable functions is


I’m really new to these hooks. My Derma menu looks like this:

[lua]function WEB()
local frame = vgui.Create(“DFrame”)
frame:SetSize(ScrW() - 200, ScrH() - 200)

local html = vgui.Create("HTML",frame)
concommand.Add( "web", WEB )[/lua]

I want that to be bound to F5.

try this:

function WebShow( ply )
ply:ConCommand( “web” )
hook.Add(“ShowSpare2”, “WebShow”, WebShow)

note that will bind it to F4. As using the bind command on a player is not allowed, you have to use one of the pre-assigned gamemode keys.

You might also try **[Player.ConCommand](**. Not sure if its also limited to that red list.

I put it in the cl_hooks, wouldn’t work :S