javascript中的多个按键操作

时间:2013-03-13 11:43:57

标签: javascript jquery css javascript-events

我有这个动画角色每次按导航键时都会改变。

此字符可以跳转,但如果我尝试使用spaceBar + rightKey。我没想到会发生任何事情。

字符正常跳转,不会跳right

我想 -

我试图在窗口中添加一个框,这样这个角色不应该穿过这个框,他只能跳过/走过它。 我想绑定键让他定向跳跃。

代码 -

if(spaceBar)
    {
        box.stop(true,false).animate({top:xPos-50},10, function(){
            box.animate({top:xPos},100);
        })

我试过

if(spaceBar,rightKey)
    {
        box.stop(true,false).animate({top:xPos-50},10, function(){
            box.animate({top:xPos},100);
        })

但这并没有成功。

了解更多信息 -

Fiddle

1 个答案:

答案 0 :(得分:0)

@da_re在他的评论中是正确的,他应该已经发布了答案。

if(spacebar && rightKey)