[Home]WikiPatches/PressCtrlSToSave

UseModWiki | WikiPatches | RecentChanges | Preferences

It is just a small Javascript hack, but I thought it might be worth sharing.

What it does:

When you press CTRL+S it will activate hit the Save-Button.

The code:

 
$UserHeader  = <<AUTOFOCUSJAVASCRIPT;
  <script language="JavaScript" type="text/javascript"><!--
    function getKey(keyStroke) {
      isNetscape=(document.layers);
      eventChooser = (isNetscape) ? keyStroke.which : event.keyCode;
      which = String.fromCharCode(eventChooser).toLowerCase();
      
      if (event.ctrlKey && which == 's') {
        document.all.Save.click();
        e.returnValue = false;
        return false;
      }
    }
    document.onkeydown = getKey;
  //--></script>
AUTOFOCUSJAVASCRIPT 
 
$UserBody    = 'onload="onLoad()"'; # Optional <BODY> tag additional content 

Credits:

The idea was taken from http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_20271998.html and modified to work with Usemod 1.0 by [Christopher Özbek].


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited March 29, 2005 4:32 pm by MarkusLude (diff)
Search: