繁体   English   中英

按下Enter键并单击?

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM