Replace dot with comma

We have a requirement in our web application to replace the dot pressed in the Numeric pad, with comma. I 've searched in the internet for a solution for this and could not find one.
Hence I had to find the following solution. (Works only in IE browser)

var dotReplace = false;
function keypressEvent(the_key) {
if(the_key == 46 && dotReplace) {
event.keyCode = 44;
}
}
function keydownEvent(the_key) {
if(the_key == 110) {
dotReplace = true;
} else {
dotReplace = false;
}
}


And in the form call the above functions for respective events.
<input name="disp" type="text" 
onkeypress="keypressEvent(event.keyCode)"
onkeydown="keydownEvent(event.keyCode)">

Working Example:
Type a dot from the numeric pad here: