2
$("#last_4_cc").keyup(function()
{
    $.post('<?php echo site_url("sales/set_last_4_cc");?>', {last_4_cc: $('#last_4_cc').val()});    
});

When doing keypress() or keydown() I get the value before the key is inputed, when I do key up, I get the val() for the after the key is inputed.

Example:

Cur Value: 333

keyPress "3" Cur Val 333

Cur Value: 333

keyUp "3" Cur Val 3333

Why is this?

Chris Muench
  • 17,444
  • 70
  • 209
  • 362

1 Answers1

5

This is the expected behavior? KeyPress and KeyDown events are supposed to be triggered before the default action is performed, KeyUp fires afterwards.

See here: http://www.quirksmode.org/dom/events/keys.html

Niko
  • 26,516
  • 9
  • 93
  • 110