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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:44:52+00:00 2026-06-03T13:44:52+00:00

All I have found about this is that there are inconsistencies among different web

  • 0

All I have found about this is that there are inconsistencies among different web browsers when it comes to key codes.

I have the following code that runs fine when pressed enter in Safari, Opera and Chrome, but not in Firefox.

I use Firefox 9.0.1.

Here are two code snippets where the problem occurs:

1)

// Post something
$('#postDiv').on('keydown', '#posttext', function(e) {
    if ((e.keyCode == 13 || e.which == 13) && !event.shiftKey) {
        post($(this));
    }
});
// Comment on a post
$('.commenttext').live('keydown', function(e) {
    if ((e.keyCode == 13 || e.which == 13) && !event.shiftKey) {
        comment($(this));
    }
});

Both functions aren’t even called.

I did some more testing only with e.which and noticed that it works when I leave out the && !event.shiftKey – apparently Firefox doesn’t know that command. Is there any alternative to that? I would like the user to be able to hit Shift + Enter without submitting the post. I have already tried the condition if (e.which==13 && e.which!=16), but to no avail.

Solution

First of all thank you for all answers! Of course it had to be e.shiftKey, not event.shiftKey! Now it works in all browsers (the only one I haven’t tried yet is Internet Explorer).

  • 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-03T13:44:55+00:00Added an answer on June 3, 2026 at 1:44 pm

    From http://api.jquery.com/event.which/

    The event.which property normalizes event.keyCode and event.charCode.
    It is recommended to watch event.which for keyboard key input.

    You shouldn’t need to use e.keyCode and you may be running into issues where e.which != 13 but e.keyCode does. Have you verified the issue continues after removing the e.keyCode evaluation out of your control structures?

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

Sidebar

Related Questions

I have about 8 entities that all have a one to one relationship with
I still have some confusion about this thing. What I have found till now
This might be a trivial question, but I have not found anything about it,
There are tons of questions about this topic, but I have a slightly altered
Recently I found about this tool easy_install that help me to easy install additional
How can I create equal height columns in CSS? All I have found searching
I have searched online but all the answers I have found were very primitive.
I'm writing an equirectangular map viewer, all the stuff I have found so far
I want to have all edges have to properties, weight and capacity. I found
I have read all the documentation I found on how to integrate Unity3D projects

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.