I'm looking for a jquery function that only allows a movements with arrow keys and backspace in a textarea, but the movements with the arrow keys don't work correctly.
function moveArrow(e){
if(e.which >= 37 && e.which <= 40){
return true;
}
return false;
}
$(document).ready(function() {
$('#installId').keypress(function (e)
{ return deleteItem(e,false) });
$('#installId').keydown(function (e)
{ return deleteItem(e,false) });
$('#installId').keypress(function (e)
{ return moveArrow(e) });
$('#installId').keydown(function (e)
{ return moveArrow(e) });
});
you have to preventDefault on other key press
$('#installId').keypress(function (e){
if(e.which < 37 || e.which > 40)
e.preventDefault();
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.