How can I pause jQuery until a condition is met?
The condition is that a SPACE is typed.... It's inside a CASE sta开发者_如何学JAVAtement:
case KEY.ATSIGN:
clearTimeout(timeout);
//alert(event.keyCode);
while(event.keyCode != 32) {
alert(event.keyCode);
timeout = setTimeout(onChange, options.delayLong);
}
break;
32 is the ascii for space... I am trying to get the subset matching feature to work in jQuery only AFTER an @ sign is typed.... Hence the case statement KEY.ATSIGN.
You can put an event handler on the keypress event on your input element and evaluate what key was pressed.
http://api.jquery.com/keypress/
精彩评论