disable receiving KEY_ input while in console

hi all

I have used this code to open a UI, but typing in chat or the console still calls the hook - very annoying. How can I do a check to make sure console or chat isn’t open when the function is called?


--run this function when the player presses a key. we use this to call other functions
local function KeyPress()

    --for inventory
    if (input.IsKeyDown(KEY_I) and (inventory_is_open == 0)) then debug_text("opening inventory") inventory_open() end

end
hook.Add("Think","KeyPress",KeyPress)


if(vgui.CursorVisible() == true) then
	return
end

Not sure if it will stop the Console issue, sure as hell stops chat issues though

[LUA]
if not gui.IsConsoleVisible() then
–shtufe
end
[/LUA]

This will stop it working while other windows are open too though won’t it, I don’t want that

is there a specific check I can do to see if the chat window is open?

thanks

Well, I’m going to take a shot in the dark and say that none of your vguis but the chatbox use keyboard input and say you can use vgui.GetKeyboardFocus()

They do, so this wont work