[英]press enter key with a click?
我有一個特殊的鼠標,它的控制是通過按鈕實現的。 我的意思是,當我按下左鍵時,焦點將向前移動,當我按下中鍵時,其焦點將向后移動,而右鍵一次單擊。 用右鍵單擊某些對象時效果不佳,因為某些例程網站無法識別單擊,因此我想用回車鍵更改提示,我的意思是當我按右鍵時我想要一個鍵輸入按下。 我不知道我是否很清楚。 這是實際的代碼:
$(":focusable").eq(0).focus();
var currentFocus=$(":focusable").eq(0);
$(document).ready(function(){
$("#prueba1").mousedown(function(e){
//1: izquierda, 2: medio/ruleta, 3: derecho
if(e.which == 3) {
//PlaySound3("http://www.soundjay.com/button/beep-06.wav");
//PlaySound3("https://www.soundjay.com/button/button-30.wav");
PlaySound4();
if(currentFocus!=undefined){
currentFocus.focus();
currentFocus.trigger('click');
if(currentFocus.prop('tagName')=='A'){
window.location.href = currentFocus.attr('href');
};
}
return false;
}
if(e.which == 2) {
PlaySound3();
var focusables= $(":focusable");
var current= focusables.index(currentFocus);
var previous = focusables.eq(current-1).length ? focusables.eq(current-1) : focusables.eq(0);
currentFocus=previous;
previous.focus();
return false;
}
if(e.which == 1) {
parar();
PlaySound();
//PlaySound3("http://www.soundjay.com/button/beep-07.wav");
var focusables= $(":focusable");
var current= focusables.index(currentFocus);
var next = focusables.eq(current+1).length ? focusables.eq(current+1) : focusables.eq(0);
currentFocus=next;
next.focus();
return false;
}
});
});
非常感謝你!
這樣右鍵單擊觸發輸入鍵。
var e = $.Event( "keypress", { which: 13 } );
$('#yourInput').trigger(e);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.