PDA

View Full Version : keypress and KeyEvent issues



UGA_Zimma
13 Jul 2009, 7:50 AM
I have a date field and want the user to be able to press "t" and have it fill in todays date. It is working but i cant figure out how to keep the "t" from printing to the screen. e.g. when t is pressed it shows up as 07/13/2009t. Does anyone know how to keep the "t" from showing up?



var aDate = new Ext.form.DateField({

name: 'a-date',
width:95,
autoheight:true,
allowBlank:true,
enableKeyEvents:true,

listeners:{
change: {
fn: function(dp,date,dateOld) {
aDateSelection = date;
}
},
keypress: {
fn: function(tf,eo){
var k = eo.getKey();

if (eo.getCharCode() == 116){return false;
tf.setValue(new Date());

}
}
}
}
});


Thanks in advanced!

UGA_Zimma
13 Jul 2009, 8:17 AM
I added the line -

.preventDefault()

- to the function and it stops the "t" from printing.