Skip to content

Instantly share code, notes, and snippets.

@KingCprey
Last active December 6, 2023 23:04
Show Gist options
  • Star 23 You must be signed in to star a gist
  • Fork 18 You must be signed in to fork a gist
  • Save KingCprey/d40f6deb8ac2949d95524448596e2f37 to your computer and use it in GitHub Desktop.
Save KingCprey/d40f6deb8ac2949d95524448596e2f37 to your computer and use it in GitHub Desktop.
FiveM IsControlPressed keys
--IsControlPressed(0,x)
local keys={}
keys[34]="A"
keys[29]="B"
keys[26]="C"
keys[30]="D"
keys[46]="E"
keys[49]="F"
keys[47]="G"
keys[74]="H"
keys[311]="K"
keys[7]="L"
keys[244]="M"
keys[249]="N"
keys[199]="P"
keys[44]="Q"
keys[45]="R"
keys[33]="S"
keys[245]="T"
keys[303]="U"
keys[0]="V"
keys[32]="W"
keys[77]="X"
keys[246]="Y"
keys[20]="Z"
keys[39]="["
keys[27]="UpArr"
keys[173]="DownArr"
keys[174]="LeftArr"
keys[175]="RightArr"
keys[19]="LAlt"
keys[168]="F7"
keys[288]="F1"
keys[289]="F2"
keys[170]="F3"
keys[166]="F5"
keys[167]="F6"
keys[56]="F9"
keys[57]="F10"
keys[344]="F11"
keys[157]="1"
keys[158]="2"
keys[160]="3"
keys[164]="4"
keys[165]="5"
keys[159]="6"
keys[161]="7"
keys[162]="8"
keys[163]="9"
keys[21]="LShift"
--citizen cod
Citizen.CreateThread(function()
local count=0
local keys={}
keys[34]="A"
keys[29]="B"
keys[26]="C"
keys[30]="D"
keys[46]="E"
keys[49]="F"
keys[47]="G"
keys[74]="H"
keys[311]="K"
keys[7]="L"
keys[244]="M"
keys[249]="N"
keys[199]="P"
keys[44]="Q"
keys[45]="R"
keys[33]="S"
keys[245]="T"
keys[303]="U"
keys[0]="V"
keys[32]="W"
keys[77]="X"
keys[246]="Y"
keys[20]="Z"
keys[39]="["
keys[27]="UpArr"
keys[173]="DownArr"
keys[174]="LeftArr"
keys[175]="RightArr"
keys[19]="LAlt"
keys[168]="F7"
keys[288]="F1"
keys[289]="F2"
keys[170]="F3"
keys[166]="F5"
keys[167]="F6"
keys[56]="F9"
keys[57]="F10"
keys[344]="F11"
keys[157]="1"
keys[158]="2"
keys[160]="3"
keys[164]="4"
keys[165]="5"
keys[159]="6"
keys[161]="7"
keys[162]="8"
keys[163]="9"
keys[21]="LShift"
local ignore={169,240,239}
while true do
Wait(0)
local i=0
while i<1000 do
if IsControlPressed(0,i) and not inside(ignore,i) then
if keys[i]==nil then
print(count .. " CONTROL PRESSED = " .. i)
count=count+1
else
print(i .. " = " .. keys[i])
break
end
end
i=i+1
end
if IsControlPressed(0,20) then
break
end
end
end)
@xenfovn
Copy link

xenfovn commented Oct 29, 2020

ok

@GHOUR1
Copy link

GHOUR1 commented Jan 16, 2021

Nice

@Sagos99
Copy link

Sagos99 commented Jun 18, 2021

thx

@Marvinzock34
Copy link

whats the number for F4 ?

@Theshadow089
Copy link

whats the number for F4 ?

["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118

@deepitche
Copy link

svp qui a le ²

@RoccoRP
Copy link

RoccoRP commented Jul 18, 2022

whats the number for F4 ?
why you skip F4 ?

@Maxim-1337
Copy link

whats the number for F4 ? why you skip F4 ?

F4 gib es nicht

@Theshadow089
Copy link

F4 doesn’t exist you can’t use F4 as key
F4 gibts nicht du kannst es nicht nutzen
If you search for “fivem key list” on google than you can find a site of cfx.docs and there you can see that F4 doesn’t exist.
Wenn du bei google “fivem key list” eingibst findest du eine seite mit der url mit cfx.docs und da kannst du F4 nicht finden

@Theshadow089
Copy link

@zorks1233
Copy link

Kann man auch eine Kombi von alt + und eine zahl oder Buchstabe zusätzlich

@Ozikos
Copy link

Ozikos commented Aug 3, 2023

what is middle key? {scroll}

@jk-htwk
Copy link

jk-htwk commented Aug 29, 2023

Kann man auch eine Kombi von alt + und eine zahl oder Buchstabe zusätzlich

Ja das geht

in der config.lua so in etwa

Config.Controls = { TPMarker = {keyboard1 = Keys['LEFTALT'], keyboard2 = Keys['E']} }

und in der client.lua

if IsControlPressed(1, Config.Controls.TPMarker.keyboard1) and IsControlJustReleased(1, Config.Controls.TPMarker.keyboard2) then ... ... end

Das wäre ein Beispiel für die linke alt Taste + E

Und F4 kann man mit Umweg auch verwenden!

config.lue
Config.DefaultOpenKey = 'F4'

client.lua
Citizen.CreateThread(function() RegisterKeyMapping('openmenu', 'Open Menu', 'keyboard', Config.DefaultOpenKey) end)

Parameter für RegisterKeyMapping hier nach zu lesen
https://docs.fivem.net/natives/?_0xD7664FD1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment