Jump to content

Close modal with esc key


fbg13
 Share

Recommended Posts

Something like this could help:

$(document).on('keydown', function (e) {

  e = e || window.event;
  var closeBtn = $('.ui-dialog-titlebar-close');

  if (e.keyCode === 27 && closeBtn.length) { // ESC
  	closeBtn.trigger('click');
  }
});

You just need to figure out the selector of the close button - I'm not sure they are all the same, but perhaps I'm wrong. 

In the next version of AdminOnSteroids (uploaded soon) there will be a feature to add custom JavaScript so you just need to place it there.

  • Like 3
Link to comment
Share on other sites

I think we should collect these keyboard improvements, put them into a Pull Request and point them towards "core", 2.8 and 3.0.

For example: One could make the Page List in Admin (both Reno and Standard, they share the same code here) way more keyboard accessible with a few lines of code. I have this prepared but originially wanted to make further improvements on links' and buttons' focus styles, but don't find the time to finish it to match my aspiration.

ProcessWire's admin themes deserve an accessibility boost :)

PS: Not just admin themes, the standard themes should lead by example as well :)

PPS: Just saw Ryan tagged it as "ToDo", yay O0

  • Like 6
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...