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

  • SEARCH
  • Home
  • 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 6166703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:22:58+00:00 2026-05-23T22:22:58+00:00

When I press . it fires the three events, keydown , keypress and keyup

  • 0

When I press . it fires the three events, keydown, keypress and keyup.

keydown
  which: 190 == ¾
  keyCode: 190 == ¾

keypress
  which: 46 == .
  keyCode: 46 == .

keyup
  which: 190 == ¾
  keyCode: 190 == ¾

When I press delete it fires two events, keydown and keyup.

keydown
  which: 46 == .
  keyCode: 46 == .

keyup
  which: 46 == .
  keyCode: 46 == .

I want to press . and be able to get the corresponding character (46 == .). But on keydown and keyup I get 190 which is ¾. On the keypress I get the correct value, but this event is not fired when I press delete.

When I press delete I get the code 46 on keydown and keyup. But the code 46 is a . and not delete.

How can I make an event to capture both keys and tell the difference, if it was a . pressed or delete key?

Page to test: http://jsfiddle.net/Eg9F3/

  • 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-23T22:22:59+00:00Added an answer on May 23, 2026 at 10:22 pm

    I’ve forced the same behavior as Firefox, example on jsFiddle

    $("textarea").keydown(function(e) {
        // if the key pressed was found on the list of specialChars
        if (specialChars[e.keyCode])
        {
            // triggers the fake event
            $("textarea").trigger("chromekeypress", e);
    
            // temporary avoid keypress from firing
            $("textarea").unbind("keypress");
            setTimeout(function(){ $("textarea").bind("keypress", handleKey); },10);
        }
    });
    
    $("textarea").keypress(handleKey); // main event
    
    $("textarea").bind("chromekeypress", chromeKeyPress); // chrome workaround
    
    function chromeKeyPress(i,e){
        e.type="chromekeypress";
        e.which = 0; // copy Firefox behavior, which == 0 means a special key pressed
        handleKey(e); // fires the main event
    }
    function handleKey(e) {
    
        // which is going to be 0 if it is a special key
        // and keycode will have the code of the special key
        // or
        // which will have the value of the key
    
        $("#r").html($("#r").html() + "\n" +
            e.type + "\n" +
            "  which: " + e.which + " == " + String.fromCharCode(e.which) + "\n" +
            "  keyCode: " + e.keyCode + " == " + String.fromCharCode(e.keyCode) + "\n" +
         "");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get a specific asp:button onclick event to fire when I press
When I press F5 in Visual Studio 2008, I want Google Chrome launched as
If you press Shift+Ctrl+T or choose Navigate > Open Type... you get the Open
I have the following code. When I press my save button, three requiredfieldvalidators run
There is a page with a form. When I press the send button, two
If I press Ctrl + B that ought to give me ASCII code 2,
When I press the standard Ctrl + E, C (an other variants) in VS2008
when I press the Maximize button on my WPF app, all the controls therein
When I press F5, everything compiles fine, but when the app is to be
When my user press Enter on the virtual android user validate entry! keyboard my

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.