Using jQuery, how do I determine that user has pressed '+'. I know that by matching keycode in the keydown event is the way to go, but that is apparently not cross platform. Since, the keycodes vary in Linux OS. Matching to charcode is also not an option because it is not cross browser. IE, of course, does no开发者_Python百科t support charcode.
Does anyone know a cross platform solution to do this? Google+ has apparently been able to achieve this.
$("#element").keyup(function(e){
if (e.keyCode == 61 || e.keyCode == 107){ // 61 for windows, 107 for mac
//do stuff
}
}
or, if you feel this isn't reliable, use
if ($.firefox){
var keycode = ..;
}
if ($.opera){
var keycode = ..;
}
// and more
where you have to change .. with certain keycode working in that browser
精彩评论