Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make buttons respond to Enter and Esc keys #286

Open
cfcoderatcodefactory opened this issue Mar 20, 2020 · 0 comments
Open

Make buttons respond to Enter and Esc keys #286

cfcoderatcodefactory opened this issue Mar 20, 2020 · 0 comments

Comments

@cfcoderatcodefactory
Copy link

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);
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant