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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:38:26+00:00 2026-06-03T17:38:26+00:00

I wonder if this … inputs.keydown(function (e) { switch (e.keyCode) { case 13: //Enter

  • 0

I wonder if this … 

inputs.keydown(function (e) {
    switch (e.keyCode) {
        case 13:    //Enter
        case 16:    //Shift
        case 17:    //Ctrl
        case 18:    //Alt
        case 19:    //Pause/Break
        case 20:    //Caps Lock
        case 27:    //Escape
        case 35:    //End
        case 36:    //Home
        case 37:    //Left
        case 38:    //Up
        case 39:    //Right
        case 40:    //Down

        // Mac CMD Key
        case 91:    //Safari, Chrome
        case 93:    //Safari, Chrome
        case 224:   //Firefox
        break;
        default:
        $(this).addClass(fill);
        break;
    }
});

… is also possible with fewer lines?
I know I could do an if-condition, but I wonder if I missed something like case 13 && 16 && …

Maybe some of you know a better practice to check all the cases and write fewer lines of code.
I’m just wondering.

Thank you in advance!

  • 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-03T17:38:27+00:00Added an answer on June 3, 2026 at 5:38 pm

    Just put the codes into an array, and then you can simply check if the value is in the array. Since you are using jQuery, you already have an inArray() method to do this.

    var keycodes = [13, 16, 17, 18, 19]; //and so on
    
    //if the keycode is not found in the array, the result will be -1
    if ($.inArray(e.keyCode, keycodes) === -1) { 
        $(this).addClass(fill);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder if this affects performance or memory consumption a lot. I need an
i wonder what this query means: $blogPost = Doctrine_Query::create()->from('BlogPost p')->where('p.slug = ?', 'doctrine-released')->execute(); could
I wonder is this a bug in chrome or jQuery, or am I misunderstanding
I really wonder why this question hasn't popped up here so far. I have
Hi (sorry for my ugly english) I wonder if this is possible to retrieve
Possible Duplicate: What does new() mean? Like in title. I wonder what this syntax
I wonder how is this possible in groovy to start an array from the
This is more a 'wonder why' than a specific issue but look at the
I wonder how to get something like this: Write copy(a, b, 2, 3) And
I wonder if anyone can help - I have this error showing recently when

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.