How to open a frame/panel pressing a key

I want to Open a Frame when I press or hold a key.
I tried something but it didn’t worked. Maybe I have to add a hook? If yes what hook ?

[lua]
function opent()
if input.IsKeyDown(KEY_C) then
bg = vgui.Create(“DFrame”)
bg:SetPos(ScrW()/2-300,ScrH()/2-250)
bg:SetSize(600,400)
bg:SetVisible(true)
bg:SetDraggable(false)
bg:SetTitle("")
bg.Paint = function()
draw.RoundedBox(0,0,0,bg:GetWide(),bg:GetTall(),bgcolor)
end

bg.btnMinim:SetVisible(false)
bg.btnMaxim:SetVisible(false)
end
end
[/lua]

How are you planning any function to be run without a hook or you calling it anywhere ?
I would say use Think hook, but it would be quite dumb.
I believe there was some hook like OnKeyPressed.

The best way to do this in my opinion is to use **[Concommand.Add

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Concommand.Add)**
Register the function you’re creating your frame with with a concommand, and then bind the key that you wish to use to that command.

Ok thanks, I will try this.