Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3453622
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:23:45+00:00 2026-05-18T09:23:45+00:00

I have an html form with a lot of text fields that all take

  • 0

I have an html form with a lot of text fields that all take only one character (think crossword puzzle). When a letter is entered in an input field, I use jQuery to jump to the next one. This works fine, except for the Swedish characters åäö (other international characters are probably affected too).

I bind an event listener to the keyup event, and use the event.keyCode and event.which to determine if the pressed key was a letter (if it was any special key, the events passes untouched).

The problem is that when I press å, ä or ö, both event.keyCode and event.which are 0. When I examine the event object in Firebug, I can’t find any attribute that seems to hold the key code.

The code looks like this:

    var crossword = $('article.crossword');

    crossword.bind('keyup', function(event) {
        var target = $(event.target, crossword);

        if (target.hasClass('crossword_letter_input')) {
            var pressedKey = event.which ? event.which : event.keyCode;
            var target_value = target.val();
            var target_tabindex;

            // Regular alphanumeric keys have keyCodes between 48 and 90.
            if (pressedKey >= 48 && pressedKey <= 90 && target_value.length) {
                target_tabindex = parseInt(target.attr('tabindex'));
                $('input.crossword_letter_input[tabindex=' + (target_tabindex + 1) + ']', crossword).focus();
            }
        }
    });

I use the keyup event in order to move focus after the character has been entered into the text field.

If you know of any jQuery plugin or vanilla JS that could replace this completely, that would also be a solution.

EDIT: I have made a temporary (and ugly) fix by inserting the following else if:

    // å, ä and ö reports keyCode 0 for some reason.
    else if (pressedKey === 0 && target_value.length) {
        target_tabindex = parseInt(target.attr('tabindex'));
        $('input.crossword_letter_input[tabindex=' + (target_tabindex + 1) + ']', crossword).focus();
    }

This way, I simply suppose that if the event.which and event.keyCode was both 0, and the length of the value in the field is greater than 0, focus should be moved to the next input. Supposing stuff without knowing doesn’t feel great though…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:23:45+00:00Added an answer on May 18, 2026 at 9:23 am

    Keycode is 0 for the right alt on keyboard. When you type a letter that requires use of this alt key you get 0 from ket code. There are other keys that also give the code == 0 (eg. the windows key on FF on linux)

    This code (taken from jquery example and changed a bit) produces what should be enough:

    <!DOCTYPE html>
    <html>
    <head>
      <script src="http://code.jquery.com/jquery-1.4.4.js"></script>
    </head>
    <body>
    
    <input id="whichkey" value="type something">
    <div id="log"></div>
    <script>$('#whichkey').bind('keypress',function(e){ 
      $('#log').html(e.type + ': ' +  e.which );
    });  </script>
    
    </body></html>
    

    when you type it gets triggered for alt+letter twice – once with which==0, next with which==correct code for the letter.

    eg.

    Where I live alt+a produces ą and goes the right code in an event after the one with 0.
    Keydown was only sent once with the 0 code in the same situation.

    codes:

    alt==0
    a==97
    ą=261
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML form that has certain fields which i am opening inside
I have a form that uses CKEditor and all works. I save the text
I have a following problem, I have HTML form that uploads a file with
I have a HTML form that accepts a comma separated list of tags, which
I have an html form and I need to populate one of the input
I have the following (repeating) html: <tr> <td>Some text</td> <td><a href=#>Click me<a/></td> <td><form><input type=hidden
i have html form i am using <a href="#" onclick="document.aa.submit()"> instead of submit button
My input tag started to go crazy... I have html form for input to
I have a html form <form action=process.php method=post> <input type=checkbox name=name[v1] /> <input type=checkbox
I have an HTML form which, when submitted by the user, will call a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.