Custom UI

After i have closed ui, it still have focus?
How do i fix it

My index file:

Donations UI
<div class="text-right mb-4">
  <button onclick="closeUI()" class="bg-red-600 px-3 py-1 rounded hover:bg-red-500">Luk</button>
</div>

<div class="flex justify-between items-center mb-8">
  <h1 class="text-4xl font-bold">Donations Menu</h1>
  <button onclick="toggleTheme()" class="px-4 py-2 bg-yellow-400 text-black rounded hover:bg-yellow-300 transition">Skift Tema</button>
</div>

<div class="text-center mb-10">
  <button
    onclick="window.open('https://discord.gg/DIT-LINK', '_blank')"
    class="px-6 py-3 bg-indigo-600 hover:bg-indigo-500 rounded text-white text-lg font-semibold transition"
  >Join Discord for at købe</button>
</div>

<div class="flex justify-center gap-6 mb-10">
  <button class="tab-btn px-4 py-2 bg-blue-600 rounded hover:bg-blue-500" onclick="showTab('biler')">Donationsbiler</button>
  <button class="tab-btn px-4 py-2 bg-blue-600 rounded hover:bg-blue-500" onclick="showTab('tilfojelser')">Tilføjelser</button>
  <button class="tab-btn px-4 py-2 bg-blue-600 rounded hover:bg-blue-500" onclick="showTab('pakker')">Custom Pakker</button>
</div>

<div id="biler" class="tab-content grid grid-cols-1 md:grid-cols-3 gap-6">
  <div class="bg-gray-800 p-4 rounded-xl shadow-lg dark:bg-gray-700">
    <img src="billeder/bil1.png" alt="Bil 1" class="w-full h-40 object-contain mb-4" />
    <h3 class="text-xl font-semibold">Bilnavn 1</h3>
    <p>Beskrivelse og pris her.</p>
  </div>

  <div class="bg-gray-800 p-4 rounded-xl shadow-lg dark:bg-gray-700">
    <img src="billeder/bil2.png" alt="Bil 2" class="w-full h-40 object-contain mb-4" />
    <h3 class="text-xl font-semibold">Bilnavn 2</h3>
    <p>Beskrivelse og pris her.</p>
  </div>
</div>

<div id="tilfojelser" class="tab-content hidden">
  <h2 class="text-2xl font-bold mb-4">Tilføjelser</h2>
  <p>Beskrivelse af ting som garage, vĂĄben, boost, emotes osv.</p>
</div>

<div id="pakker" class="tab-content hidden">
  <h2 class="text-2xl font-bold mb-4">Custom Pakker</h2>
  <p>Beskrivelse af pakker: VIP, Ultimate, osv.</p>
</div>

Client.lua

local nuiOpen = false

RegisterCommand(“donate”, function()
SetNuiFocus(true, true) – fokus til UI (mouse + keyboard)
SendNUIMessage({ action = “show” })
nuiOpen = true
print(“[donation_ui] UI åben og fokus sat”)
end, false)

RegisterNUICallback(“closeUI”, function(data, cb)
print(“[donation_ui] closeUI callback modtaget”)
SetNuiFocus(false, false) – fjern fokus
SendNUIMessage({ action = “hide” }) – skjul UI (ekstra sikring)
nuiOpen = false
cb({ status = “ok” }) – svar til NUI
print(“[donation_ui] Fokus frigivet og UI skjult”)
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if nuiOpen then
if IsControlJustReleased(0, 322) then – ESC-tasten
print(“[donation_ui] ESC trykket: lukker UI”)
SetNuiFocus(false, false)
SendNUIMessage({ action = “hide” })
nuiOpen = false
print(“[donation_ui] Fokus frigivet efter ESC”)
end
end
end
end)

While the NUI has focus, the IsControlJustReleased does not register any hotkeys because the focus is on the UI (duh!) , The most straight solution is to handle the NUI closure on the UI itself and tell the Lua part to release the focus