[dev] Keyboard shortcuts

Marcus I. Ryan marcus@riboflavin.net
Wed Nov 20 19:33:21 2002


I've been playing a little with keyboard shortcuts a little today.  I
think it's a feature worth having, but needs to be done "properly" (i.e.
with a Browser object, etc.).  However, just so the code doesn't
disappear, the example I used was setting Ctrl-A to mark all messages
selected in the mailbox view.  I added the following code to the top of
imp/templates/mailbox/javascript.inc:

function enableCapture(enable)
{
    if (enable) {
        document.addEventListener('keypress', processShortcuts, true);
    } else {
        document.removeEventListener('keypress', processShortcuts, true);
    }
}

function processShortcuts(e)
{
    if (e.ctrlKey && (e.charCode == 97 || e.keyCode == 65)) {
        selectFlagged(0,false);
        e.stopPropagation();
    }
}

enableCapture(true);

-- 
Marcus I. Ryan, marcus@riboflavin.net
-----------------------------------------------------------------------
 "Love is a snowmobile racing across the tundra and then suddenly it
 flips over, pinning you underneath.  At night, the ice weasels come."
                 -- Matt Groening
-----------------------------------------------------------------------



More information about the dev mailing list