Changed onkeydown to onkeyup, so it behaves more predictably.
Previously with onkeydown and onkeypress, the event got called before or after the text changed, so there was no way to properly support it on all browsers.