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 5964597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:27:42+00:00 2026-05-22T19:27:42+00:00

Simple question — Does anyone know of a reliable cross-browser function to get the

  • 0

Simple question — Does anyone know of a reliable cross-browser function to get the character typed from a keydown event? I can write one from the quirksmode grid but would rather not re-invent the wheel for something so simple yet so non-standard.

Let me clarify:

There is no way to do this simply using event.keyCode or event.which. The overall logic is something like:

  • get keycode
  • detect shift, ctrl
  • if ctrl, ignore
  • create map of keycodes with and without shift key
    • example map {186 : ';', 187 : '=', 188 : ',', ....}
    • need a separate map for shift key modifier
    • map needs to change depending on browser (especially Safari Mac which has keycodes like 60,000)
  • if keycode is in map, return mapped key
  • if keycode is not in map, normalize numbers, apply shift modifier key if necessary, return String.fromCharCode(key)

It’s not a simple solution, which is why I’m looking for a pre-made one 🙂

  • 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-22T19:27:43+00:00Added an answer on May 22, 2026 at 7:27 pm

    Are you willing to use jQuery?

    $("input").bind("keydown",function(e){ var value = this.value + String.fromCharCode(e.keyCode); }
    

    I believe that switching to the keypress event would solve the issue mentioned in your comment. Would the code below meet your requirments?

    $("input").bind("keypress",function(e){ var value = this.value + String.fromCharCode(e.keyCode); }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question, does a list in Java hold objects by value or reference? If
simple question mainly for simplifying purposes but... currently using var categoryList = []; $('#share').children().each(function()
Simple question: do I have to delete or delete [] c ? Does the
Simple question, but couldn't find the answer. When the function 'enkelpost'is called anywhere in
Simple question. I need to get a file that has been added to a
Simple question; How do you read the return value of a function that is
Simple question, but I didn't know what's the keywords to Google. Suppose we want
Simple question... Why does this release crash my app when I click on a
Simple question here, and I know there are lots of kludgy ways to do
Simple question: I want to open a URL using the Default Browser, so I

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.