I have an input on which I want specific behavior when a character is inserted, but I want the default behavior to be on shortcuts like ctrl+ cand ctrl+ v.
Here's the html:
<input type="text" onkeypress="onInputKeyPress(event)" />
and javascript:
function onInputKeyPress(event) {
if (event.charCode >= 32) {
event.preventDefault();
}
}
This works fine in IE and Chrome, but not in Firefox. This is because when I use ctrl+ cor ctrl+ v, onkeypressit is not called in IE and Chrome, but it calls the call in Firefox.
So, I tried to insert this code at the beginning of my handler:
if (event.ctrlKey) {
// leave default behavior for shortcuts
return true;
}
Now my custom processing is not called when I press ctrl+ c, but the shortcut still does not work (the text is not copied to the clipboard).
- , Firefox ?