Changed keydown to keyup.

Ideally, using oninput is even better (in the latest browsers that support it), because it detects all possible ways that input can be changed, e.g. cut, delete from context menu, etc.