I'm trying to write something similar to a 'placeholder' polyfill. I would like to catch the keyup event on an input field and get the char the user entered, so i have this code:
$elem.on('keyup',function(e){
var $this = $(this),
val = $this.val(),
code = (e.keyCode ? e.keyCode : e.which);
console.log(String.fromCharCode(code));
});
The problem is this always returns an Uppercase version of the pressed char, how can i know if the pressed char was uppercase or lowercase?
I know keypress
gives the pressed char but it does not activate on all keypress events (like backspace).
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…