Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/common/extensions/docs/static/experimental.keybinding.html

Issue 10833071: Renaming the 'keybinding' permission to 'commands'. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!-- BEGIN AUTHORED CONTENT -->
2 <p>
3 The keybinding API allows you to add keyboard shortcuts that trigger actions in
4 your extension. An action can be opening the browser action or page action popup
5 or sending a command to the extension.
6 </p>
7
8 <h2 id="manifest">Manifest</h2>
9 <p>
10 In addition to the "experimental" permission you must declare the "keybinding"
11 permission in your extension's manifest to use this API and set manifest_version
12 to (at least) 2.
13 </p>
14
15 <pre>{
16 "name": "My extension",
17 ...
18 <b> "permissions": [
19 "experimental",
20 "keybinding",
21 ]</b>,
22 ...
23 }</pre>
24
25 <h2 id="usage">Usage</h2>
26 <p>The keybinding API allows you to define specific commands, and bind them to a
27 default key combination. Each command your extension accepts must be listed in
28 the manifest as an attribute of the 'commands' manifest key. Note: Combinations
29 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the
30 AltGr key.</p>
31
32 <pre>{
33 "name": "My extension",
34 ...
35 <b> "commands": {
36 "toggle-feature-foo": {
37 "suggested_key": {
38 "default": "Ctrl+Shift+Y",
39 "mac": "Command+Shift+Y"
40 },
41 "description": "Toggle feature foo"
42 },
43 "_execute_browser_action": {
44 "suggested_key": {
45 "windows": "Ctrl+Shift+Y",
46 "mac": "Command+Shift+Y",
47 "chromeos": "Ctrl+Shift+U",
48 "linux": "Ctrl+Shift+J"
49 }
50 },
51 "_execute_page_action": {
52 "suggested_key": {
53 "default": "Ctrl+E"
54 "windows": "Alt+P",
55 "mac": "Option+P",
56 }
57 }
58 }</b>,
59 ...
60 }</pre>
61
62 <p>In your background page, you can bind a handler to each of the commands
63 defined in the manifest (except for '_execute_browser_action' and
64 '_execute_page_action') via onCommand.addListener. For example:</p>
65
66 <pre>
67 chrome.experimental.keybinding.onCommand.addListener(function(command) {
68 console.log('Command:', command);
69 });
70 </pre>
71
72 <p>The '_execute_browser_action' and '_execute_page_action' commands are
73 reserved for the action of opening your extension's popups. They won't normally
74 generate events that you can handle. If you need to take action based on your
75 popup opening, consider listening for an 'onDomReady' event inside your popup's
76 code.
77 </p>
78 <!-- END AUTHORED CONTENT -->
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698