IE10 and IE11 can’t type “t” or “T”

Today I had the opportunity to solve a problem with a login form on an old web application. The problem had to do with users using Internet Explorer 10 or Internet Explorer 11 and had a “t” or T” in their username or password. If the user typed the “T” key, nothing new was displayed in the box.
This was very curious, as the “T” key appeared to be the only key affected. I had a sneeking suspicion that javascript was the culprit, but I wasn’t sure where. Anxious to find out what the issue was, I loaded the login page and fired up the Developer Tools by pressing F12. I then clicked on the Debugger tab, followed by the pause button.
At this point I tried to type a “T”. I was brought to a legacy javascript function put in place to cancel keystrokes for refresh. It was looking for event.keyCode == 116. I hovered over event.keyCode and discovered it was 84. This shouldn’t cause the event cancel. I continued stepping through pressing F11. This brought me out of the function without a cancel as I expected.
I continued out of the function and pressed F11 once more and was very surprised when I discovered the function was called a second time. This time the event.keyCode was set to 116. This should be the F5 (Refresh/Reload) key. The fact that the function was called a second time was unsettling to me. I searched the code to determine where the function was being called and found this golden gem:
// Additional code for NS
if (navigator.appName==”Netscape”) {
 document.addEventListener(“keypress”,showDown,true);
}
document.onkeydown = showDown;
Apparently, once upon a time we were trying to special case Netscape Navigator. This code was now being called as well as the existing call to onkeydown. After removing this old Netscape special case, the expected functionality returned.
So if you find yourself staring at unexpected functionality with newer versions of IE, check your code for legacy checks and hacks in the javascript.
Have you encountered other legacy javascript gotchas? Let us know in the comments.

Leave a Reply

Your email address will not be published. Required fields are marked *