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

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

Issue 9465005: Updating the doc to reflect the new experimental.keybinding API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 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
Property Changes:
Added: svn:eol-style
+ LF
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.
12 </p>
13
14 <pre>{
15 "name": "My extension",
16 ...
17 <b> "permissions": [
18 "experimental", "keybinding",
Mike West 2012/02/24 15:14:28 Nit: Separate lines for clarity.
19 ]</b>,
20 ...
21 }</pre>
22
23 <h2 id="usage">Usage</h2>
24 <p>The keybinding API allows you to define specific commands, and bind them to a
25 default key combination. Each command your extension accepts must be listed in
26 the manifest as an attribute of the 'commands' manifest key. Note: Combinations
27 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the
28 AltGr key.</p>
29
30 <pre>{
31 "name": "My extension",
32 ...
33 <b> "commands": {
34 "toggle-feature-foo": {
35 "key": "Ctrl+Shift+Y",
36 "description": "Toggle feature foo"
37 },
38 "browserAction": {
39 "key": "Ctrl+Shift+B"
40 },
41 "pageAction": {
42 "key": "Alt+P"
43 }
44
45 }</b>,
46 ...
47 }</pre>
48
49 <p>In your background page, you can bind a handler to each of the commands
50 defined in the manifest (except for 'browserAction' and 'pageAction') via
51 onCommand.addListener. For example:</p>
52
53 <pre>
54 chrome.experimental.keybinding.onCommand.addListener(function(command) {
55 console.log('Command:', command);
56 });
57 </pre>
58
59 <p>The 'browserAction' and 'pageAction' commands are reserved for the action of
60 opening your extension's popups. They won't normally generate events that you
61 can handle. If you need to take action based on your popup opening, consider
62 listening for an 'onDomReady' event inside your popup's code.
63 </p>
64 <!-- END AUTHORED CONTENT -->
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/js/api_page_generator.js ('k') | chrome/common/extensions/extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698