-
5 Jul 2008 1:56 AM #1
Get keycode on keypress, keydown or keyup in textfield
Get keycode on keypress, keydown or keyup in textfield
Hello,
i am trying to add a check for password-fields if caps-lock is active.
Therefore I want to use my old function "check_capslock(e)". I don't know how to map that function to a textfield. I found various methods to do, but nothing works. I downloaded the newest version of ExtJs today.
Here is my last try. I think "*" will not work, but I want to call that function if ANY character is pressed.
But even using "key: 'abcd'" does return me the keycode within the "e"-object.Code:var map = new Ext.KeyMap(field_password.getId(), { key: "*", fn: function(e) { checkCapsLock(e); } });
Best regards,
Bjoern
-
5 Jul 2008 9:48 AM #2Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28
why not just listen to the KEYUP event?


Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
6 Jul 2008 4:24 AM #3
-
6 Jul 2008 5:31 AM #4Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28
evt.getCharCode()

Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
6 Jul 2008 5:45 AM #5
I tried this, but firebug says "getCharCode" is not a function:
Code:field_password.on('keyup',function(e,el) { alert(e.getCharCode()); });
-
6 Jul 2008 5:48 AM #6Sencha - Community Support Team
- Join Date
- Mar 2007
- Location
- Frederick MD, NYC, DC
- Posts
- 16,167
- Vote Rating
- 28
Look at the docs


Event is the second param.
Jay Garcia @ModusJesus || Modus Create co-founder
Ext JS in Action author
Sencha Touch in Action author
Get in touch for Ext JS & Sencha Touch Touch Training
We are also working on Video-based Sencha Touch training: Check it out here.
-
6 Jul 2008 5:56 AM #7
-
15 Jul 2008 12:45 PM #8
There is NO KEYUP event on the TextField.
This solution does not work.
Even with the undocumented property enableKeyEvents: true
for TextField http://extjs.com/forum/showthread.php?p=160289
Still the same question:
How to listen on keypressed or keyup events on Ext.form.TextField ??
-----------------------------------------------------------------------------------
well, I found the solution.
the on method must be called NOT on the Ext.form.TextField object (surprise!)
but on the Ext.form.TextField.getEl() function (?? why is this not documented??)
like this
Code:var inputField = new Ext.form.TextField({}); inputField .getEl().on('keyup',function(el,e) { alert("test"); }
-
16 Aug 2008 8:26 PM #9
I have tried those ways to implement the on event method, but they are all not worked. However I found this snippet code worked:
new Ext.form.TextField({
height : 24,
width : 225,
listeners : {
specialkey : function(field, e) {
if (e.getKey() == Ext.EventObject.ENTER) {
-
20 Oct 2009 1:00 PM #10


Reply With Quote