The basic difference between onchange and onkeypress is that onchange is triggered when user edits values in text box/text area and loses the focus. On the other hand, onkeypress is called on every key press while text box still have the focus.
In short, onchange event happens when this form element loses focus with a different value than it had when it gained focus and onkeypress triggers when key is clicked while this form element has focus.
Hence if you just want to check whether the text box have some modified value or not (for checking unsaved changes), you may opt for onChange instead of onkeyPress. But if you want to make sure that user is typing only numbers then you will have to use onkeypress.