Derma Menu open does KeyPress not getting called anymore?

Well the title sums it up. I want to open a Menu on Tab Press, and close it when the user presses Tab again(And only that way!). And well it opens but it doesnt get called later anymore!

Here is my script:
[lua]
function ScoreboardShow(p,key)

if !key == IN_SCORE then return end


if TabMenu then
	
	if TabMenu:IsVisible() then
		
		TabMenu:SetVisible(false)
		print("Close?")
	else
		
		TabMenu:SetVisible(true)
		print("Open?")
	end
	
else
	
	CreateTabMenu()
	print("Create?")
	
end
print("Normal")

end
hook.Add(“KeyPress”,“AltKey”,ScoreboardShow)
[/lua]
And console output:



Create?
Normal


and thats it.
I cant do anything anymore. Does someone know how I could work around that?

Methinks it’s a problem with your CreateTabMenu. Post that code.

Ok Here it is:

[lua]
function CreateTabMenu()

TabMenu = vgui.Create("DFrame")
TabMenu:SetTitle("Menu. (Close by using TAB)")
TabMenu:SetDeleteOnClose(false)
TabMenu:ShowCloseButton(false)
TabMenu:Center()


TabMenu:MakePopup()

end

[/lua]
Not much actually. I wanted first that the Toggle Works.

I think you’re going to have to use the input.IsKeyDown function in a think hook of the frame, since KeyPress is only called when you’re in game.

Ah ok. Well isnt there a much more efficient way?

Well I’d say you have a problem when you never set the size of the DFrame. Make sure you do that before you call Center(), otherwise it won’t work.

Yeah, as said I will do that once I managed to solve it. I think I will do it in an timer of 0.1 because think is a bit too often for that.