When user is required to enter only uppercase or lowercase characters in an input box or text area, one would think of finding solution using JavaScript. Always there will be better ways of handling things. In spite of using JavaScript, try with css.
For example: <input type="text" style="text-transform: uppercase;" >
Note that this is for display purpose. When user enters, lowercase characters, still the input is considered as lowercase characters.
For changing the value, you still need to use onblur.
i.e.. <input type="text" style="text-transform: uppercase;" onblur="this.value= this.value.toUpperCase()" >
Still this approach is better because, using onkeypress, will invoke function for each key pressed.