I don’t know if I should even really consider this a script resource, more a base events styled tool.
I made this when I first found out that there was no RegisterKeyMapping available for RedM, so until there is, this resource will help you optimize your framework by using it as a wrapper to prevent having multiple loops throughout your resources, instead just relying on the events it sends to process the information.
As I find more keys to add with proper names I’ll update this resource.
Here is an example of how I used this to reduce the resource usage of my scenes script, without having these loops running on multiple resources, it might have a decently high usage, but will save that usage from your other resources. (my usage was about 0.08ms~)
RegisterNetEvent("nh-keylistener:keyPressed", function(eKeyPress)
if eKeyPress == "DEL" then
DeleteScene()
elseif eKeyPress == "RIGHTBRACKET" then
HideScenes()
end
end)
RegisterNetEvent("nh-keylistener:keyReleased", function(eKeyPress)
if eKeyPress ~= "HOME" then return end
CreateScene()
end)
If you need instructions on installation/use just read the Readme on the github!
Enjoy!