I’m making a bind menu for my TTT server and using PlayerButtonDown to listen for key presses, then I’ll run a client side console command to bind that key to something for them.
However the hook is only responding to mouse presses, and no keyboard presses.
This code makes a DFrame which says “Press the key you you want to bind to <action>”
When the user presses a key I want that DFrame to close and bind the key for them. However it is only picking up mouse presses and no keyboard presses whatsoever.
Any help would be appreciated thanks!
bindList.OnRowSelected = function( lst, index, pnl ) local Frame = vgui.Create( "DFrame" ) Frame:SetSize( 400, 80 ) Frame:SetTitle( "Assign Key" ) Frame:SetVisible( true ) Frame:SetDraggable( false ) Frame:ShowCloseButton( false ) Frame:MakePopup() Frame:Center() local DLabel = vgui.Create("DLabel",Frame) DLabel:SetSize(390,20) DLabel:SetText("Press key to bind to ".. pnl:GetColumnText(index)) DLabel:Center() timer.Simple(0.1, function() --In a timer so pressing the bind button doesn't instantly close the menu and assign left mouse. hook.Add( "PlayerButtonDown", "ListenForKey", function( ply, key ) --This hook is only responding to mouse presses and not keyboard. print( "Key pressed is: " .. key ) hook.Remove( "PlayerButtonDown", "ListenForKey" ) Frame:Close() --Where bind assignment through console command will go end ) end) end
(User was banned for this post ("Wrong section. Try Developer Discussion next time." - Kiwi))