[英]press enter key with a click?
I have a special mouse that its control is with the buttons. 我有一个特殊的鼠标,它的控制是通过按钮实现的。 I mean that when I press left button focus go forward, when I press middle focus go behind and the right one press a click. 我的意思是,当我按下左键时,焦点将向前移动,当我按下中键时,其焦点将向后移动,而右键一次单击。 It is not working good in some objets with the right button because sometines the website doesnt' recognize the click so I was thinking to change the clck with a enter key, I mean when I press the right button I want a key enter push. 用右键单击某些对象时效果不佳,因为某些例程网站无法识别单击,因此我想用回车键更改提示,我的意思是当我按右键时我想要一个键输入按下。 I don't know If I was very clear. 我不知道我是否很清楚。 This is the actual code: 这是实际的代码:
$(":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;
}
});
});
Thank u so much! 非常感谢你!
Trigger enter key on right click like this. 这样右键单击触发输入键。
var e = $.Event( "keypress", { which: 13 } );
$('#yourInput').trigger(e);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.