// ==UserScript== // @name EChart_KeyboardShortcuts3 // @namespace oscar // @include */casemgmt/forward.jsp?action=view&* // @description Within the E-chart, Alt+1 to Save, Alt+2 to Sign/Save, Alt+3 to Sign/Save/Bill. // @grant none // ==/UserScript== // created by Darius Opensource (function(){ document.addEventListener('keydown', function(theEvent) { //theEvent.stopPropagation(); //theEvent.preventDefault(); // var theKeyCode = theEvent.charCode;// || event.which; // var theKey = String.fromCharCode(theKeyCode); var theKey = theEvent.key; var theAltKey = theEvent.altKey; var theCtrlKey = theEvent.ctrlKey; var theShiftKey= theEvent.shiftKey; switch(true){ case theAltKey && theKey== 1: // Save var theTarget = document.evaluate("id('save')/span/input[contains(@src,'media-floppy.png')]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue; theTarget.click(); break; case theAltKey && theKey== 2: // Sign and Save var theTarget = document.evaluate("id('save')/span/input[contains(@src,'note-save.png')]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue; theTarget.click(); break; case theAltKey && theKey== 3: // Sign, Save, and Bill var theTarget = document.evaluate("id('save')/span/input[contains(@src,'dollar-sign-icon.png')]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue; theTarget.click(); break; case theAltKey && theKey== 4: // Exit var theTarget = document.evaluate("id('save')/span/input[contains(@src,'system-log-out.png')]",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE,null).singleNodeValue; theTarget.click(); break; /* //*[@id="saveImg"] case theAltKey && theCtrlKey && theShiftKey && theKey=='': //TO DO: The action to be performed for the above keyboard shortcut break; */ } }, true); })();