Jump to content
MakeWebGames

JS - How to stop Tab key from blur the input box?


Recommended Posts

Posted (edited)

Hello guys,

I have a frustrating problem. I want to stop the caret from changing input focus (jump outside) when I press tab. Instead remain in the input field.

Basically I want to create an auto-complete word when I press tab.

What I've tried something similar to this:

 


<input type="text" onKeyUp="preventTab(e)" onKeyPress="preventTab(e)" onKeyDown="preventTab(e)">
<script>
function preventTab(e){
   e.preventDefault();
   documentQuery(...).focus();
   return false;
}
</script>

 

All keys trigger this function except tab key.

- Please delete the thread. The code worked on KeyDown, no idea why it didn't worked before.

Edited by HazardBoy

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...