开发者

Jquery wait for keypress [duplicate]

开发者 https://www.devze.com 2023-04-04 17:54 出处:网络
This que开发者_StackOverflow中文版stion already has answers here: Closed 11 years ago. Possible 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

精彩评论

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