Open F4 Menu

I’m making an F4 menu but cant figure out how to check if the user has pressed F4

For console commands you would use concommand, for chat commands you would use:


hook.Add("OnPlayerChat" , "OpenChatMenu" , function(ply , text)

if ply == LocalPlayer() then
	
if string.lower(text) == "!open" then

OpenPanel()

end

end

end)

but what would i use to enable the f4 menu with the f4 button? I have tried things like KeyPress but that is only for IN_ENUMS ( Buttons binded to things )

Any help is appreciated

GM:PlayerButtonDown

Could you give me an example of how it would work?
I have tried



hook.Add("PlayerButtonDown","CheckF4",function(ply,key)

if key == KEY_F4 then
 OpenPanel()
end

end)

But when i press f4 nothing happens

You can check if KEY_F4 is down with

input.WasKeyPressed in a

GM:CreateMove hook.

Thank you! For those interested, it looks like this:



hook.Add("CreateMove","CheckF4",function(ply,key)

if input.WasKeyPressed( KEY_F4 ) then
	
OpenPanel()

end

end)