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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:27:39+00:00 2026-06-14T10:27:39+00:00

Do the numbers on a numeric keypad have a different keycode than the numbers

  • 0

Do the numbers on a numeric keypad have a different keycode than the numbers at the top of a keyboard?

Here is some JavaScript that is supposed to run on the keyup event, but only if the keycode is between 48 and 57. Here is the code:

$('#rollNum').keyup(function(e) {
    if(e.keyCode >= 48 && e.keyCode <= 57) { //0-9 only
        var max = 15;
        var textLen = $(this).val().length;
        var textLeft = max - textLen;
        . . . 

My problem is that this code only runs in response to the numbers entered at the top of the keyboard, but does not run in response to numbers entered from the numeric keypad.

I’m thinking the answer must be that the numeric keypad has different keyCode values, but how do I find out what those are?

  • 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-06-14T10:27:40+00:00Added an answer on June 14, 2026 at 10:27 am

    The keycodes are different. Keypad 0-9 is Keycode 96 to 105

    Your if statement should be:

    if ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105)) { 
      // 0-9 only
    }
    

    Here’s a reference guide for keycodes


    — UPDATE —

    This is an old answer and keyCode has been deprecated. There are now alternative methods to achieve this, such as using key:

    if ((e.key >= 48 && e.key <= 57) || (e.key >= 96 && e.key <= 105)) { 
      // 0-9 only
    }
    

    Here’s an output tester for event.key, thanks to @Danziger for the link.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several different numbers in a group that range in sizes and would
i have large numbers of text files and i am in problem that i
I have a list with numeric strings, like so: numbers = ['1', '5', '10',
Is it possible to have Android's numeric keypad display for an EditText (the one
JavaScript comes with 64bit float numbers for all numeric literals, and the storage layout
I have a site where users enter a numeric code of 10 numbers: xxxxxxxxxx
I have a group of numeric functions in Clojure that I want to validate
Have a numeric nvarchar values with some extra-symbols For example 1/2, 9/6, 14A They
I have an HTML textarea where the user inserts numeric serial numbers. These are
I have a simple numeric keypad with buttons which work as expected. You click

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.