Introduction to Controls in FiveM Development

When developing for FiveM, understanding controls is essential. Controls allow you to detect player input—such as pressing keys, using the mouse, or interacting with a controller—and respond with custom actions in your scripts. Whether you’re creating roleplay commands, mini-games, or custom interactions, mastering controls is a core skill for any FiveM developer.

In this post, we’ll cover:

  • What controls are in FiveM
  • Common control types and key mappings
  • How to detect and respond to controls in scripts
  • Best practices for working with controls

What Are Controls in FiveM?

In FiveM, controls are inputs from the player’s device. These include:

  • Keyboard keys (e.g., E, F, H)
  • Mouse buttons (e.g., left-click, right-click)
  • Gamepad buttons (e.g., A, B, X, Y on Xbox controllers)

Controls are handled using native functions in FiveM scripts, allowing you to trigger events, interact with peds, vehicles, objects, and even your server UI.


Detecting Controls in Scripts

The most commonly used functions for detecting controls are:

  • IsControlPressed – Checks if a control is currently being held down.
  • IsControlJustPressed – Checks if a control was pressed just once.
  • IsControlReleased – Checks if a control was released.

Example: Detecting a Key Press

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0) -- Loop every frame
        if IsControlJustPressed(1, 51) then -- 51 is the "E" key
            print("Player pressed E!")
        end
    end
end)

In this example, when the player presses E, the script prints a message. You could easily replace this with actions like opening a shop, starting a job, or interacting with a ped.


Common Control Mappings

Controls in FiveM are defined by control IDs. Here are some frequently used ones:

ActionControl IDDescription
E51Interaction key
F23Enter/exit vehicle or special action
SPACE22Jump
LEFT CTRL36Sprint / crouch modifier
LEFT MOUSE24Fire / primary action
RIGHT MOUSE25Aim / secondary action
G47Drop weapon or custom action

A full list of controls can be found in the FiveM Native Reference.


Practical Uses of Controls

Controls are essential for creating interactive features in FiveM:

  1. Job interactions – Press E to start deliveries, open menus, or interact with NPCs.
  2. Custom game mechanics – Trigger abilities, mini-games, or special actions.
  3. Vehicle and weapon control – Detect when players enter vehicles, aim, or shoot.
  4. UI interaction – Open inventories, maps, or custom interfaces with a key press.

By combining controls with events, you can build responsive, immersive gameplay experiences.


Best Practices for Controls

  1. Avoid conflicts – Use keys that don’t interfere with default GTA V actions.
  2. Use custom control groups – Organize inputs to handle multiple devices (keyboard, mouse, controller).
  3. Debounce actions – Prevent multiple triggers from a single key press unless intentional.
  4. Provide feedback – Show notifications or UI hints when a key press triggers an action.

In our Learn FiveM Development course, you’ll practice using controls through projects and challenges—like opening custom menus, interacting with NPCs, or triggering server events—so you gain real-world experience handling player input.

Scroll to Top