protz/GMail-Conversation-View — pull request #676 by blerner (2012-12-24 07:00:13+00:00)
Title: Custom keys

I've implemented key customization for Conversations, along the lines of Issue #668. The code does three things:

* Exposes ConversationKeybindings so that extensions can add new listeners and/or change existing ones:

```javascript
// Move an existing hotkey
ConversationKeybindings.bindings.Generic.X =
ConversationKeybindings.bindings.Generic.A;
// Change modifiers of an existing hotkey
ConversationKeybindings.bindings.Generic.X[0].mods.shiftKey = true;
// Delete an existing hotkey
delete ConversationKeybindings.Generic.A;
// Register a new function
ConversationKeybindings.registerCustomListener(
"sayHello",
function myFunc() {
Components.utils.reportError("My custom func is running!");
});
// Create a new hotkey
ConversationKeybindings.bindings.Generic.A =
[{ mods: { metaKey: false, ctrlKey: false }, func: "sayHello" }];
```

* Creates a keybinding editor in the Conversations options page. You can remove existing keys, add new ones, or modify existing ones. Gray modifiers are inessential, red-strikethru modifiers must not be pressed, and green ones must be pressed for the hotkey to fire (corresponding to the logic in message.js, where a modifier field missing, false, or true, respectively).

* Persists the edited keys across TB sessions, and allows restoring the default keys.

I've also created a "Do Nothing" event listener, which allows Conversations to swallow keypresses, if the user wants to disable default behaviors (at least, while Conversations has keyboard focus...)