【发布时间】:2013-04-04 09:42:10
【问题描述】:
我需要检测事件keydown和keyup中字符的大小写
$('body').keydown(
function(event) {
var charCode = (event.which) ? event.which : event.keyCode;
var char = String.fromCharCode(charCode);
console.log(char + " is down pressed");
}
);
$('body').keyup(
function(event) {
var charCode = (event.which) ? event.which : event.keyCode;
var char = String.fromCharCode(charCode);
console.log(char + " is up pressed");
}
);
你可以在这里试试:http://jsfiddle.net/8dqwW/
即使没有按大写锁定,它也总是返回大写字母。
在这两个事件中,我怎样才能检测到字母的大小写是大写还是小写?
【问题讨论】:
标签: jquery case-sensitive keydown keyup