Set NUI focus is it broke?

Hi does anyone know why set NUI focused doesn’t work for me I do setnuifocus true true if I press e but if I do setnuifocus false false if I press escape it doesn’t nothing?

It is because you have NUI focus. The game isn’t reading your key presses. You need to add an onkeyup listener into the NUI to listen for key presses and send an event back to the script to set the focus off.

document.onkeyup = function (data) {
    if (data.which == 27) { // Escape key
        $.post('http://bhut/NUIFocusOff', JSON.stringify({}));
    }
};
RegisterNUICallback('NUIFocusOff', function()
    SetNuiFocus(false, false)
end)
1 Like