Ext JS - 获取真实字符类型时遇到问题?
这是我的问题...考虑到这段代码...
'keydown': function (textThis,e) {
var cc = String.fromCharCode(e.keyCode);
Ext.MessageBox.alert('Caracter',cc);
}
我总是得到我输入的字符,但是是大写的...即使我输入的是减号...我该如何解决这个问题?感谢来自阿根廷科尔多瓦的提前致谢
Here is my problem... Considering this code...
'keydown': function (textThis,e) {
var cc = String.fromCharCode(e.keyCode);
Ext.MessageBox.alert('Caracter',cc);
}
I always get the the char I type but in uppercase... Even if I type it in minus... How can I solve this ?. Thankx in adavnce from Cordoba Argentina
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每次击键都会触发
keydown
和keyup
事件(例如shift
键)。他们报告密钥(“密钥”没有小写或大写)。keypress
报告组合笔画(例如 SHIFT 加 A)和 ASCII 代码(正确表示大写/小写)的单个事件。解决方案是监听
keypress
事件。如果您支持旧版浏览器,则应该使用此代码(根据此网站) :更多详细信息请参阅此 stackoverflow 问题。
The
keydown
andkeyup
events fire for every single keystroke (e.g. for theshift
key as well). They report the key (the 'key' doesn't have a lower or upper-case).keypress
reports a single event for combined strokes (e.g. SHIFT plus A) and the ASCII code (with correct representation of upper/lower case).The solution is to listen to the
keypress
event. If you are supporting older browsers you should go with this code (according to this website):More details in this stackoverflow question.