View Full Version : Key Event Detection plus Shift

06-13-2007, 09:21 PM
function doSomething(e) {
var code;
if (!e) var e = window.event;
if (e.keyCode) code = e.keyCode;
else if (e.which) code = e.which;
var character = String.fromCharCode(code);
alert('Character was ' + character);


This function allows me to see what key was pressed. However, what I want to do, is get the character, not the key. What I mean, is that if you type 3 you get a character of 3. If you type #, (Shift+3) then you also get 3.

I want to get the character that was entered. How do I do this?
Thank you for the help.

Philip M
06-13-2007, 10:35 PM
Have a look at this:-