Sha256: efb2fb95d3060699542c5951b753c0a17414445c7c592ae030b18954f2aa0831
Contents?: true
Size: 717 Bytes
Versions: 81
Compression:
Stored size: 717 Bytes
Contents
/** * Version 0.0.1 * Catch the CTRL+S keys combination and trigger a callback * Didier Lafforgue */ $.cmd = function(key, callback, args, options) { var keyCode = key.charCodeAt(0); var altKeyCode = keyCode + (32 * (keyCode < 97 ? 1 : -1)); options = (options || { ignoreCase: false }); if (!options.ignoreCase) altKeyCode = null; doc = options.document || window.document; $(doc).keydown(function(e) { var isCtrl = false; if (!args) args = []; // IE barks when args is null if (e.ctrlKey || e.metaKey) isCtrl = true; if ((keyCode == e.which || altKeyCode == e.which) && isCtrl) { e.preventDefault(); callback.apply(this, args); return false; } }); };
Version data entries
81 entries across 81 versions & 3 rubygems