views:

21

answers:

2

Hi

I found a couple of keypress scripts but I need a key binding in Chrome and Safari for command key and s (like saving files in desktop applications). Does anybody know about such a script or plugin? jquery is in place but pure JavaScript solutions are also welcome!

thanks

+1  A: 

Using

jQuery(document).bind('keydown', 'Ctrl+1',function (evt){  
  setTimeout("console.log('ctrl+1')",50);return false;
});

is fine. To determine what keys will fire which event i recommend strongly this w3.org test page.

Thariama
A: 

this works fine for me any recommendations? I'm not a good JavaScripter :)

<script src="jquery.js" type="text/javascript"></script>

<script>
var last_key = 0;
var code_meta_key = 91;
var code_s = 83;

$(document).keydown(function(event){ 

  if (last_key == 91 && event.keyCode == 83) {
    setTimeout("console.log('boom')",50);
    return false;
  }

  last_key = (event.keyCode == 91) ? 91 : 0;
});
</script>
funkycottleti