Garry's Mod Wiki

Garry's Mod Wiki

  boolean PANEL:OnKeyCodePressed( number keyCode )

Description

Called whenever a keyboard key was pressed while the panel is focused.

This is not run for ESC/"cancelselect" binding.

Issue Tracker: 2886

Arguments

1 number keyCode
The key code of the pressed key, see KEY enum.

Returns

1 boolean
Return true to suppress default action.

Example

Prints some text into console when the player presses any button while the panel is opened. In this example the panel is opened via the testvgui console command.

concommand.Add( "testvgui", function( ply ) local DFrame = vgui.Create( "DFrame" ) -- The name of the panel, we don't have to parent it DFrame:SetPos( 100, 100 ) -- Set the position to 100x by 100y DFrame:SetSize( 300, 200 ) -- Set the size to 300x by 200y DFrame:SetTitle( "Derma Frame" ) -- Set the title in the top left to 'Derma Frame' DFrame:MakePopup() -- Make the frame take user's input function DFrame:OnKeyCodePressed( ... ) print( "OnKeyCodePressed", ... ) -- Print something when a key is pressed end end )

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...