Capture CTRL + S cross browser with ExtJS 4.x and avoid browser action

I want to stop the default browser CTRL + S and ask my RIA to save the form data while the user presses this key combination for our application.

We use ExtJS 4.1.x

A similar solution here using jQuery: Best cross-browser method to capture CTRL + S using jQuery?

+4
source share
1 answer

This is how I usually do it in ExtJS applications (the last case example), it seems to work well for me:

// attach key navigation to document Ext.getDoc().on('keypress', function(event, target) { if (event.ctrlKey && !event.shiftKey) { event.stopEvent(); switch(event.getKey()) { case event.LEFT : this.shiftTabs(-1); break; case event.RIGHT : this.shiftTabs(1); break; case event.DELETE : this.closeActiveTab(); break; case event.F4 : // this is actually the "S" key this.saveAll(); // handler break; // other cases... } } }); 
+3
source

All Articles