Ok so what is the difference in .keypress and .keydown/.keyup? At present I am using .keydown which returns a .which value of 38 for my key, now if i change it to .keypress it returns a value of 109 for that same key. What is the difference and why are the values different for the same key?
If you press a button it fires a keydown
and releasing it fires a keyup
. The keypress
usually comes between those two.
keydown
and keyup
talk about which key has been changed. keypress
tells which character that key represents.
Note that this is all browser-dependent!
See this article about the differences between the key events as implemented on various browsers.