I have some code like this to take over the space bar's function:
$(document).keypress(function (e) {
e.preventDefault();
if (e.which == 32) {
// func
}
});
Unfortunately this destroys all key's defaults.
This:
$(document).keypress(function (e) {
if (e.which == 32) {
e.preventDefault();
// func
}
});
Is unfortunately ineffective.
How can I make it preventDefault of only spacebar?
Thanks.