我有一个特殊的鼠标,它的控件是按钮。我的意思是,当我按下左键时,焦点向前移动,当我按下中间焦点后面,右键按下一下。使用正确的按钮在一些objets中效果不佳,因为网站没有'识别点击,所以我想用输入键改变clck,我的意思是当我按下右键我想要一个键输入push。我不知道如果我很清楚。这是实际的代码:
$(":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;
}
});
});
非常感谢你!
答案 0 :(得分:1)
在此处右键单击触发输入键。
var e = $.Event( "keypress", { which: 13 } );
$('#yourInput').trigger(e);