Closed prashil40 closed 2 years ago
Hi @prashil40,
Notiflix is not focusing listen to the keyboard events. So, you can please create your custom solution.
An example/simple solution can be as below.
// Listener
var documentKeyupEventListener = function (event) {
// Enter
if (event.keyCode === 13) {
window.document.getElementById('NXConfirmButtonOk').click();
}
// ESC
if (event.keyCode === 27) {
window.document.getElementById('NXConfirmButtonCancel').click();
}
};
// Adding Listener
window.document.addEventListener('keyup', documentKeyupEventListener);
// Notiflix
Notiflix.Confirm.show(
'Notiflix Confirm',
'Do you agree with me?',
'Yes',
'No',
function okCb() {
// Removing Listener
window.document.removeEventListener('keyup', documentKeyupEventListener);
},
function cancelCb() {
// Removing Listener
window.document.removeEventListener('keyup', documentKeyupEventListener);
},
);
Thanks, Furkan
Is your feature request related to a problem? Please describe.
Yes, whenever I try to use Notiflix.Confirm.Show for delete confirmation, I have to select OK / Cancel button with mouse
Describe the solution you'd like
There can be an option to enable/disable keys like "Enter" (for Ok) and "Esc" (for Cancel)