As promised the release of my custom shortcut key library. Its a bit late but have been hung up with customers all week. And we all know the customer is always right/prioritized.
The way the script works is by attaching to the Keyup event in the DOM. The reason for using keyup, is to make sure the function isn't fired several times when you press the keycombo. Keyup is only fired one time per keypress.
To install the script make a folder called isv/script in the root for your CRMWEB folder. Place the js file in this folder. (This is just my way, do it anyway you like)
Next you need to load the script on the form where you want to make custom shortcut keys. This is done using the following codesnippet that i got from Henry Cordes's blog (http://www.henrycordes.nl/post/2008/05/External-js-file-and-CRM.aspx) on the forms onLoad code.
function load_script (url)
{
var x = new ActiveXObject("Msxml2.XMLHTTP");
x.open('GET', url, false); x.send('');
eval(x.responseText);
var s = x.responseText.split(/\n/);
var r = /^function\s*([a-z_]+)/i;
for (var i = 0; i < s.length; i++)
{
var m = r.exec(s[i]);
if (m != null)
window[m[1]] = eval(m[1]);
}
}
load_script("/isv/scripts/CoreAmbition.ShortcutKeys.js");
Once the code is loade, you need to attach the keycomboes you want to trigger functions. This is done using the following code.
// Define functions for use on keycombos
msgbox1 = function() {
alert("msgbox1");
}
// Parameteres are KeyCode, Shift, Ctrl, Alt, function call or definition
// React to Shift-D and run the function msgbox1
AddKeyCombo(68,true,false,false,msgbox1);
// Define the function call directly in the function.
// React to Shift-Ctrl-D
AddKeyCombo(68,true,true,false, function() { alert("msgbox2"); });
You should now be up and running. It is now up to you to make the functionality that you want to happen on the shortcut keys.
Just remember NOT to use combos already used by IE or the shortcuts used by CRM. You can see them here.
http://www.microsoft.com/dynamics/crm/using/services/keyboardshortcuts.mspx
Download the Shortcut library and an eksample file here
CoreAmbition.ShortcutKeys.zip (2.73 kb)
Let me know if and what you choose to use this for, and if you make some cool shortcut functions, please share the here