Reputation: 3923
I'm getting strange characters when the keyup event is fired.
For example pressing -
shows up as ½
on screen.
$('#c').append(String.fromCharCode(e.which).toLowerCase());
What should I do?
Upvotes: 1
Views: 116
Reputation: 318182
You need to use the keypress
event, not the keyup
or keydown
events, as those would cause this exact problem.
change :
$('#a').on('keyup', function(e) {
$('#c').append(String.fromCharCode(e.which).toLowerCase());
});
to :
$('#a').on('keypress', function(e) {
$('#c').append(String.fromCharCode(e.which).toLowerCase());
});
Upvotes: 2