Player Binding

I am trying to bind a key with player, used Think hook and worked fine just it spams much, there’s no problem with spamming, i can fix it but the real problem is it does my commands every time people press that key, the part i hate is that it works on chat and console too, I can use KeyPressed but i want some other KEY_, used input.IsKeyDown for my functions:

[lua]
hook.Add(“Think”, “BindSomething”, function()
if input.IsKeyDown(KEY_N) then
LocalPlayer():ConCommand(“command1”)
end
if input.IsKeyDown(KEY_B) then
LocalPlayer():ConCommand(“command2”)
end
end)
[/lua]

Thanks!

-didn’t read-

If it’s a custom console command that you’ve created, then instead of executing ConCommand() you could simply call the function(s) that do what you want with the player.
If the command comes from the game or some outside addon, I guess you could hook the command and add the key check in the command’s handler function as well, so if it’s called by typing it in console or chat, the player still needs KEY_N or KEY_B pressed for respective commands to do action.

My hook works, just i want it to work same as ply:KeyPressed, What i mean is i don’t want it to work on console or chat, i want it to work only when player is in game and walking / standing on a side.

Look a bit harder.

input.IsKeyTrapping() should tell you if a text box is focussed or not.