I’m building a calculator, and am using the following:
jQuery(function($) {
$('#Quantity').keyup(function() {
console.log($(this).val());
});
});
Q1: Is keyup() the right event to be using?
Q2: Why is Firebug telling me “The ‘charCode’ property of a keyup event should not be used. The value is meaningless”? I noticed that it’s doing the same thing as I type this question into Stackoverflow, so I must not be doing something too awfully wrong.
It appears because jQuery uses its own
eventobject instead of a native browser one, and in the process of creating this object reads every possible property of an event, includingcharCode:Firefox rightly warns you that you don’t want to read
charCodein the case of keyup events, not realising that you’re just copying it, not actually doing anything with it. Consequently any page you create with jQuery keyup/keydown handlers will spit endless warnings.(IMO, jQuery should not bother copy this property. In the only case you actually want to use it—
keypress—you can just use plain oldwhich.)