+ Start a Discussion
CyberfireCyberfire 

Javascript keybinding for keyboard shortcuts?

Does anyone know whether it is possible to associate keybindings through Javascript to allow users to perform functions in Salesforce through "hotkeys"? There is a HotKey app that Salesforce published a while back, which allows you to perform one of the "Create New" functions from the dropdown menu in the sidebar.

 

Here are some concepts that I'm working with in order to make Salesforce less click driven and more keystroke based:

 

Alt+11 = Sends a predefined email template to the lead

Alt+T   = Creates a completed activity on the record, with a predefined subject line

 

Does anyone know if this is possible?

prageethprageeth

Hello Cyberfire;

 

You can do something like this if your hotkey is combined with ctrl key. But not with Alt key.

<apex:page>

<script>

function validateKey(evt){

var key = evt.keyCode? evt.keyCode : evt.charCode;

if (key == 17) { // 'ctrl + q' is pressed

myFunction();

}

}

function myFunction(){

alert('Hello, You pressed the hotkey.');

}

document.onkeypress = validateKey;

</script>

</apex:page>

 

Press "ctrl + q" after the page is rendered to see the result. 

CyberfireCyberfire

Prageeth, thanks for the suggestion - do you know if the script can actually trigger native salesforce events? I know that I can trigger alerts, which could be useful for information.

 

It would be similar to the codeblock that you have below, but would reference instead a Salesforce object or function through apex or something similar.