For data entry screens keyboard shortcuts are an incredibly useful way to make the form faster and more user friendly. Users who bang at the screen all day will learn the shortcuts surprisingly fast and thank you for saving their wrists. Of course this should be used together with other techniques such as proper keyboard focus management and ensuring there is no auto-postback causing an undue delay.
With the jQuery library included with SalesLogix it is pretty easy to set up, here is an example of how I am using it to trigger certain buttons when Ctrl+N, Ctrl+R etc are pressed:
$(document).keydown(function (e) { if (e.which == 'N'.charCodeAt(0) && e.ctrlKey) { if ($("#<%# btnNextFax.ClientID %>").is(":visible")) // this check is to prevent them from slamming repeatedly on Ctrl+N $("#<%# btnNextFax.ClientID %>").click(); return false; } if (e.which == 'R'.charCodeAt(0) && e.ctrlKey) { if ($("#<%# btnRefresh.ClientID %>").is(":visible")) $("#<%# btnRefresh.ClientID %>").click(); return false; } if (e.which == 'D'.charCodeAt(0) && e.ctrlKey && $("#<%# btnDeleteSelected.ClientID %>").is(":visible")) { // short delay so that the handler is over by the time the prompt shows up setTimeout(function () { $("#<%# btnDeleteSelected.ClientID %>").click(); }, 100); return false; } if (e.which == 'A'.charCodeAt(0) && e.ctrlKey && $("#<%# btnSelectAll.ClientID %>").is(":visible")) { $("#<%# btnSelectAll.ClientID %>").click(); return false; } });
It’s important to remember to only register the handler once… and if you register in a dialog smartpart you need to make sure to undo it (otherwise it will try to trigger the button again even once the dialog is hidden)! This can be done calling $(document).unbind(‘keydown’, myfunction) (in that case you have to make sure you keep a reference to your handler).