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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:28:08+00:00 2026-05-13T23:28:08+00:00

I am fighting with a very strange javascript behavior on a jQuery UI widget

  • 0

I am fighting with a very strange javascript behavior on a jQuery UI widget I’m trying to fix.
IE7 (win XP), jQuery 1.2.6 (yes, it’s an old version).

The widget is a combo-box, which captures keyboard events and has special behaviors for the arrow keys.

When I try to type the “&” character into the flexbox input field, I get strange behavior.

The flexbox has some code like:

//initialization
$myInputElement.keypress($.flexbox.process_key);
$.flexbox.process_key = function process_key(e) {
    $.flexbox.flexboxFromInput(this).processKey(e);
    return true;
};

//on the flexbox object's prototype:
...
    processKey: function processKey(e) {
        var mod = 0;
            if (typeof (e.ctrlKey) !== 'undefined') {
                if (e.ctrlKey) mod |= 1;
                if (e.shiftKey) mod |= 2;
            } else {
                if (e.modifiers & Event.CONTROL_MASK) mod |= 1;
                if (e.modifiers & Event.SHIFT_MASK) mod |= 2;
            }
            ...
            switch (e.keyCode) {
                   case 38: // up
                       this.prevResult();
                       break;
                   case 40: // down
                       if (this.getCtr().is(':visible')) this.nextResult();
                       else this.flexboxDelay(true);
                       break;
               ...etc.
           }
    }
...

When I introduce a logging statement, what I find is that pressing “&” (shift+7) produces three keypress events:

INFO: Flexbox> processKey, keyCode=16, ctrl=false, shift=true
INFO: Flexbox> processKey, keyCode=55, ctrl=false, shift=true
INFO: Flexbox> processKey, keyCode=38, ctrl=false, shift=true

Apparently, keyCode 38 is both the up arrow key and the ASCII code for ampersand??

As I was writing this, it occurred to me that I can detect the keypress as “shift+7” (keyCode 55) to treat it as the ampersand key, then set some kind of flag to ignore the next keypress (which is the 38). This seems like a horrible hack.

Does anybody have a better way to differentiate between special characters such as “&” and the arrow keys in IE?

  • 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-13T23:28:08+00:00Added an answer on May 13, 2026 at 11:28 pm

    This is what I ended up doing:

        /*
         * Hack around a wierd behavior in IE where "&%'(" have the same keyCodes
         * as the arrow keys.
         */
            if (keyCodeIn(e.keyCode, 55, 53, 57) && (mod & 2) && !(mod & 1)) {
                this.ignoreNextArrowKey = true;
            }
            else if (222 === e.keyCode && !(mod & 2) && !(mod & 1)) {
                this.ignoreNextArrowKey = true;
            }
            else if (keyCodeIn(e.keyCode, 38, 37, 39, 40) && this.ignoreNextArrowKey) {
                this.ignoreNextArrowKey = false;
                return;
            }
    
            //...
    
            function keyCodeIn(keyCode) {
                for(var i = 1; i < arguments.length; i++) {
                    if (arguments[i] === keyCode) {
                        return true;
                    }
                }
                return false;
            }
    

    Hope this helps somebody. If you are reusing this code, you may have to adjust your usage of keyword ‘this’, depending on what object it refers to (here, it’s a javascript object associated with the flexbox widget).

    Edit: I updated this code, and removed the regular expression test that was previously there, which I discovered was buggy.

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

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In JAXB 2.0, the setValidating() method has been deprecated. Now,… May 14, 2026 at 9:03 am
  • Editorial Team
    Editorial Team added an answer You need to make sure you've created a web application… May 14, 2026 at 9:03 am
  • Editorial Team
    Editorial Team added an answer This is not a reference to a reference; there is… May 14, 2026 at 9:03 am

Related Questions

Summary: Can I program a thick client game in C without reinventing wheels ,
Anyone out there used MATLAB's javaObject() function with a JAR file that uses JNI?
I am a newbie in Quartz and I am fighting to understand this stuff
I'm thinking of switching from using PHP to Python for web applications, but I
I am struggling with a nullable datetime column [DateInsp] in an ASP.NET app which

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.