Garry's Mod Wiki

input

The input library allows you to gather information about the clients input devices (mouse & keyboard), such as the cursor position and whether a key is pressed or not.

Methods

number input.CheckKeyTrapping()
Returns the last key captured by key trapping.
number, number input.GetCursorPos()
Returns the cursor's position on the screen
number input.GetKeyCode( string button )
Gets the button code from a button name. This is opposite of input.GetKeyName.
string input.GetKeyName( number button )
Gets the button name from a numeric button code. The name needs to be translated with language.GetPhrase before being displayed. Despite the name of the function, this also works for the full range of keys in Enums/BUTTON_CODE.
boolean input.IsButtonDown( number button )
Gets whether the specified button code is down. Unlike input.IsKeyDown this can also detect joystick presses from Enums/JOYSTICK
boolean input.IsControlDown()
Returns whether a control key is being pressed
boolean input.IsKeyDown( number key )
Gets whether a key is down
boolean input.IsKeyTrapping()
Returns whether key trapping is activate and the next key press will be captured.
boolean input.IsMouseDown( number mouseKey )
Gets whether a mouse button is down
boolean input.IsShiftDown()
Gets whether a shift key is being pressed
string input.LookupBinding( string binding, boolean exact = false )
Gets the match uppercase key for the specified binding.
string input.LookupKeyBinding( number key )
Returns the bind string that the given key is bound to.
input.SelectWeapon( Weapon weapon )
Switches to the provided weapon on the next CUserCmd generation/CreateMove call. Direct binding to CInput::MakeWeaponSelection.
input.SetCursorPos( number mouseX, number mouseY )
Sets the cursor's position on the screen, relative to the topleft corner of the window
input.StartKeyTrapping()
Begins waiting for a key to be pressed so we can save it for input.CheckKeyTrapping. Used by the DBinder.
string input.TranslateAlias( string command )
Translates a console command alias, basically reverse of the alias console command
boolean input.WasKeyPressed( number key )
Returns whether a key was initially pressed in the same frame this function was called. This function only works in Move hooks, and will detect key presses even in main menu or when a typing in a text field.
boolean input.WasKeyReleased( number key )
Returns whether a key was released in the same frame this function was called. This function only works in Move hooks, and will detect key releases even in main menu or when a typing in a text field.
boolean input.WasKeyTyped( number key )
Returns whether the key is being held down or not. This function only works in Move hooks, and will detect key events even in main menu or when a typing in a text field.
boolean input.WasMouseDoublePressed( number button )
Returns whether a mouse key was double pressed in the same frame this function was called. If this function returns true, input.WasMousePressed will return false. This function only works in Move hooks, and will detect mouse events even in main menu or when a typing in a text field.
boolean input.WasMousePressed( number key )
Returns whether a mouse key was initially pressed in the same frame this function was called. If input.WasMouseDoublePressed returns true, this function will return false. This function only works in Move hooks, and will detect mouse events even in main menu or when a typing in a text field.
boolean input.WasMouseReleased( number key )
Returns whether a mouse key was released in the same frame this function was called. This function only works in Move hooks, and will detect mouse events even in main menu or when a typing in a text field.

Page Links


Special Pages


Wikis

?

Render Time: 28ms

DB GetPage 3
Generate Html 2
SaveChanges (1) 8
Render Body 0
Render Sidebar 12