PDA

View Full Version : Wrong key code in keypress event (4.1)



juger
13 Feb 2013, 1:15 PM
The key code defined for ENTER and RETURN in the Ext.EventObject class is 13, but when you press those keys, the event actually returns 12.

scottmartin
13 Feb 2013, 2:43 PM
Can you provide a test case that displays this behavior?

Scott.

juger
13 Feb 2013, 2:54 PM
Sure, sorry I forgot to follow the guidelines for reporting a bug



Ext version tested:

Ext 4.1
Browser versions tested against:

Chrome
Description:

The key code defined for ENTER and RETURN in the Ext.EventObject class is 13, but when you press those keys, the event actually returns 12..
Steps to reproduce the problem:

Create a textfield and listen for the keypress event
The result that was expected:

When ENTER or RETURN is pressed, it should return the values of e.ENTER or e.RETURN, which are defined as 13
The result that occurs instead:

When ENTER or RETURN is pressed, it returns 12
Test Case:

Code:



xtype:'textfield',
enableKeyEvents: true,
width: 150,
listeners: {
keypress: function(obj, e) {
console.log('key code: ' + e.button);
console.log('ENTER: ' + e.ENTER);
console.log('RETURN: ' + e.RETURN);
}
}


Output



key code: 12
ENTER: 13
RETURN: 13