PDA

View Full Version : [3.3.1] Textfield 'keypress' event doesn't fire on BACKSPACE for some browsers



nsolsen
9 Dec 2010, 4:31 AM
I noticed that for Ext.form.TextField, the 'keypress' event doesn't fire on BACKSPACE in IE, Chrome and Safari. It does fire correctly in Firefox and Opera. For all browsers the 'keydown' and 'keyup' events fire on BACKSPACE.

Is this intended to be so? If so, it should be documented in the event handler descriptions for Ext.form.TextField, as this cross browser difference may come as a surprise -- like it did for me.. ;)

Here's an example. Drop it into a subdirectory of the SDK examples directory, and load it into a browser.



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title id='title'>Textfield keypress handler, BACKSPACE ignored"</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all-debug.js"></script>
<script type="text/javascript">
Ext.BLANK_IMAGE_URL = '../../resources/images/default/s.gif';
Ext.onReady(function() {
var form = new Ext.FormPanel({
layout: 'form',
frame: true,
title: 'No keypress event fires for BACKSPACE key on IE, Chrome, Safari',
width: 400, height: 200,
renderTo: Ext.getBody(),
items: [{
xtype: 'textfield', fieldLabel: 'Textfield', name: 'f1',
enableKeyEvents: true,
listeners: {
keypress: function() { console.log("keypress"); },
keydown: function() { console.log("keydown"); },
keyup: function() { console.log("keyup"); }
}
}]
});
});
</script>
</head>
<body>
</body>
</html>