SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru Nick Carlson's Avatar
    Join Date
    Aug 2003
    Location
    Denver
    Posts
    644
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems with the [Tab] key.

    Hi everyone,

    I building a javascript text editor, but I'm having a bit of a problem with the [tab] key. When in a text box such as this, I need the user to be able to press tab and (expectedly) have the cursor move forward 4 spaces (or any other number of spaces).

    Instead, the browser seems to control tab, and it moves the cursor focus to the next element on the page.

    Does anyone know if there is anyway around this? Thank you.

  2. #2
    I meant that to happen silver trophybronze trophy Raffles's Avatar
    Join Date
    Sep 2005
    Location
    Tanzania
    Posts
    4,662
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I don't think so, tab seems pretty hard to do anything with. Gmail can hijack ctrl+s for itself, but tab still shifts focus to the button after the textarea.

    This is expected behaviour in a browser and you shouldn't try to change this. You will likely annoy lots of users if you manage to hijack "tab" to do something else than the default expected behaviour.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I leave the default tab events alone- that is how you navigate to the next element. Don't mess with what many of your users count on.

    To insert tab characters into a textarea, I listen for keydowns from the textarea, and insert a tab ('\t') at the cursor when the user presses shift+spacebar.

  4. #4
    SitePoint Guru Nick Carlson's Avatar
    Join Date
    Aug 2003
    Location
    Denver
    Posts
    644
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for both of your comments.

    Using shift + space-bar is a good idea.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •