javascript-如果启用了Caps Lock,则ExtJS显示消息

如果用户在输入密码时打开大写锁定,我想添加一条消息.到目前为止,这是我尝试过的.

 {
     xtype:'textfield',itemId: 'field_password_login',fieldLabel: 'Password',inputType: 'password',allowBlank: false,listeners:
     {
         keypress: function(tf,e)
         {
             if (e.getKey() != 13 && e.getKey() != 10 && e.getKey() != 127)
             {
                 if ((!e.shiftKey && (e.getKey() >= 65 && e.getKey() <= 90)) || ((e.getKey() >= 97 && e.getKey() <= 122) && e.shiftKey))
                 {
                     Ext.getCmp("app_idCAPSIndicator").setText("CAPS LOCK is ON");
                     Ext.getDom("app_idCAPSIndicator").style.color = "navy";

                 }
                 else
                 {
                     Ext.getCmp("app_idCAPSIndicator").setText("");
                 }
             }
             if (e.getKey() == 13)
             {
                 Ext.Msg.alert("Enter pressed");
             }
         }
     }
 },{
     xtype: 'label',fieldLabel: '',labelWidth: 90,labelAlign: 'left',labelSeperator: '',id: 'app_idCAPSIndicator'
 }

但这行不通.我没有错误消息知道发生了什么.我在这里做错了什么?

最佳答案
添加enableKeyEvents:true,如果为true,则为HTML输入字段启用键事件的代理

{
     xtype:'textfield',enableKeyEvents: true,

相关文章

前言 做过web项目开发的人对layer弹层组件肯定不陌生,作为l...
前言 前端表单校验是过滤无效数据、假数据、有毒数据的第一步...
前言 图片上传是web项目常见的需求,我基于之前的博客的代码...
前言 导出Excel文件这个功能,通常都是在后端实现返回前端一...
前言 众所周知,js是单线程的,从上往下,从左往右依次执行,...
前言 项目开发中,我们可能会碰到这样的需求:select标签,禁...