This has been haunting me for a while now.
While one might think that is a easy thing to do, just listen to the keydown og keyup event, og even using jquery’s keypress event and adding a
preventdefault on the event, or returning false – then youre done. 🙂
But hey – NOT working on the mobile chrome browser.
So it seems that anothe technique must be used.
After a long trial and error period, i came across a new event called input
And voila:
var your_element = document.getElementById('your_element');
your_element.addEventListener('textInput', function(e) {
if (e.data.charCodeAt(0) == 32) {
e.preventDefault();
return false;
}
return true;
});
/Renzo
[adsense type=”button”]