-
Notifications
You must be signed in to change notification settings - Fork 484
Description
Found nothing in the documentation about this.
I want to be able to bind the Enter and Esc keys to the different buttons in the various Vex pop-up variants.
Example Code (which doesn’t work):
vex.dialog.buttons.YES.text = 'Continue';
vex.dialog.buttons.NO.text = 'Cancel';
vex.dialog.confirm({
message: 'Any kind of question',
callback: function(value) {
if (value) {
console.log('confirm clicked');
function2invoke(param1, param2);
}
else {
console.log('cancel clicked');
differentFunction2invoke(param1, param2);
}
}
})
// make OK button respond to enter key and cancel button respond to escape key
$(document).bind("keyup.key13", function(event) {
var keycode = (event.keyCode ? event.keyCode : event.which);
console.log('keycode clicked: ' + keycode);
if (keycode == '13') {
console.log('confirm clicked');
function2invoke(param1, param2);
}
});
$(document).bind("keyup.key27", function(event) {
var keycode = (event.keyCode ? event.keyCode : event.which);
console.log('keycode clicked: ' + keycode);
if (keycode == '27') {
console.log('cancel clicked');
differentFunction2invoke(param1, param2);
}
});