How close when backspace is pressed

Hello ,
I try too do a function for close the inventory when backspace is pressed .
I have try this but that don’t work .

    while true do
        if isInInventory = true then
            if IsControlJustReleased(0, Keys['BACKSPACE']) then
                    action = "close",
                SetNuiFocus(false, false)


Can someone help me please .
Thanks .

If the inventory has nui focus it the game won’t receive the control presses so you probably have to do this check in NUI

Maybe a function CloseMenu it depends on what your using but

IsinInventory = false may work it depends on wha6 that local does

His inventory is probably working with NUI. He’ll need to listen for a key press (or a mouse press somewhere on the screen, like a cross button) into his html document and then create a NUI callback that closes the menu.