It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center
                            
                        
                    
                
                                已关闭8年。
            
                    
可以仅使用JS来完成箭头键导航吗?

不像超级鱼等第三方。

最佳答案

是的,这是一个骨架:

document.onkeydown = function(evt)
{
    evt = evt || window.event;
    if (evt.keyCode == 37)
    {
        //do something
    }
    else if (evt.keyCode == 38)
    {
        //do something
    }
    else if (evt.keyCode == 39)
    {
        //do something
    }
    else if (evt.keyCode == 40)
    {
        //do something
    }
};

关于javascript - 带键盘导航的Javascript下拉菜单,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8209294/

10-12 13:45