开发者

KeyUp jQuery in Facebook iFrame app

I'm making a facebook game and the users asked me to make the game start by pressing spacebar, because clicking on a button wastes their time. I tried to make it by this code:

jQuery("body").focus().bind('keyup', function (e) { if ( e.keyCode == 32 ){
   startgame();
}});

But this code doesn't work in the app (http://apps.facebook.com/typepractice/), but it works in the site (http://typepractice.php5.sk/). Is Facebook blocking the key events? Please, he开发者_C百科lp me.


I find that the Spacebar-to-start doesn't work on either the facebook app, or the site. I think your jQuery may simply not work.


I made it work by adding event to a button, not a body element. It works now

jQuery(".game input[type='button']")
.focus()
.css({"cursor":"pointer"})
.click(startgame)
.keyup(function (e) {
       if ( e.keyCode == 32 ){
           startgame();
           return false;
        }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜