开发者

Jquery wait for keypress [duplicate]

This que开发者_StackOverflow中文版stion already has answers here: Closed 11 years ago.

Possible Duplicate:

JavaScript execute until keypress

I've got a function that needs to be played, after the function does it's job the user has to press a key to continue. Does anybody know how to pause the function until a key is pressed?

Thanks in advance


var pause = true;

function bla() {
    // your function does stuff

    while(pause) {
        $(document).bind('keypress', function(e) {
            if(e.keyCode == 13) {
                pause = false;
            }
        });
    }

    // go on doing stuff...
}

Its only idea.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜