OLD | NEW |
1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: | 1 <!DOCTYPE html><!-- This page is a placeholder for generated extensions api doc.
Note: |
2 1) The <head> information in this page is significant, should be uniform | 2 1) The <head> information in this page is significant, should be uniform |
3 across api docs and should be edited only with knowledge of the | 3 across api docs and should be edited only with knowledge of the |
4 templating mechanism. | 4 templating mechanism. |
5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a | 5 3) All <body>.innerHTML is genereated as an rendering step. If viewed in a |
6 browser, it will be re-generated from the template, json schema and | 6 browser, it will be re-generated from the template, json schema and |
7 authored overview content. | 7 authored overview content. |
8 4) The <body>.innerHTML is also generated by an offline step so that this | 8 4) The <body>.innerHTML is also generated by an offline step so that this |
9 page may easily be indexed by search engines. | 9 page may easily be indexed by search engines. |
10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> | 10 --><html xmlns="http://www.w3.org/1999/xhtml"><head> |
11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | 11 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
12 <link href="../css/print.css" rel="stylesheet" type="text/css" media="print"
> | 12 <link href="../css/print.css" rel="stylesheet" type="text/css" media="print"
> |
13 <script type="text/javascript" src="../../../../third_party/jstemplate/jstem
plate_compiled.js"> | 13 <script type="text/javascript" src="../../../../third_party/jstemplate/jstem
plate_compiled.js"> |
14 </script> | 14 </script> |
15 <script type="text/javascript" src="../../../../../third_party/json_minify/m
inify-sans-regexp.js"> | 15 <script type="text/javascript" src="../../../../../third_party/json_minify/m
inify-sans-regexp.js"> |
16 </script> | 16 </script> |
17 <script type="text/javascript" src="../js/api_page_generator.js"></script> | 17 <script type="text/javascript" src="../js/api_page_generator.js"></script> |
18 <script type="text/javascript" src="../js/bootstrap.js"></script> | 18 <script type="text/javascript" src="../js/bootstrap.js"></script> |
19 <script type="text/javascript" src="../js/sidebar.js"></script> | 19 <script type="text/javascript" src="../js/sidebar.js"></script> |
20 <meta name="description" content="Documentation for the chrome.experimental.ke
ybinding module, which is part of the Google Chrome extension APIs."><title>chr
ome.experimental.keybinding - Google Chrome Extensions - Google Code</title></he
ad> | 20 <title>Experimental.keybinding - Google Chrome Extensions - Google Code</title
></head> |
21 <body doc-family="extensions"> <link href="../css/ApiRefStyles.css" rel="styl
esheet" type="text/css"> | 21 <body doc-family="extensions"> <link href="../css/ApiRefStyles.css" rel="styl
esheet" type="text/css"> |
22 <link href="../css/shared.css" rel="stylesheet" type="text/css"> | 22 <link href="../css/shared.css" rel="stylesheet" type="text/css"> |
23 <div id="devModeWarning" class="displayModeWarning"> | 23 <div id="devModeWarning" class="displayModeWarning"> |
24 You are viewing extension docs in chrome via the 'file:' scheme: are you exp
ecting to see local changes when you refresh? You'll need run chrome with --allo
w-file-access-from-files. | 24 You are viewing extension docs in chrome via the 'file:' scheme: are you exp
ecting to see local changes when you refresh? You'll need run chrome with --allo
w-file-access-from-files. |
25 </div> | 25 </div> |
26 <div id="branchWarning" class="displayModeWarning"> | 26 <div id="branchWarning" class="displayModeWarning"> |
27 <span>WARNING: This is the <span id="branchName">BETA</span> documentation. | 27 <span>WARNING: This is the <span id="branchName">BETA</span> documentation. |
28 It may not work with the stable release of Chrome.</span> | 28 It may not work with the stable release of Chrome.</span> |
29 <select id="branchChooser"> | 29 <select id="branchChooser"> |
30 <option>Choose a different version... | 30 <option>Choose a different version... |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 <li><a href="themes.html">Themes</a></li> | 179 <li><a href="themes.html">Themes</a></li> |
180 </ul> | 180 </ul> |
181 </li> | 181 </li> |
182 </ul> | 182 </ul> |
183 </div> | 183 </div> |
184 <script> | 184 <script> |
185 initToggles(); | 185 initToggles(); |
186 </script> | 186 </script> |
187 <div class="g-unit" id="gc-pagecontent"> | 187 <div class="g-unit" id="gc-pagecontent"> |
188 <div id="pageTitle"> | 188 <div id="pageTitle"> |
189 <h1 class="page_title">chrome.experimental.keybinding</h1> | 189 <h1 class="page_title">Experimental.keybinding</h1> |
190 </div> | 190 </div> |
191 <!-- TABLE OF CONTENTS --> | 191 <!-- TABLE OF CONTENTS --> |
192 <div id="toc"> | |
193 <h2>Contents</h2> | |
194 <ol> | |
195 <li> | |
196 <a href="#manifest">Manifest</a> | |
197 <ol> | |
198 </ol> | |
199 </li><li> | |
200 <a href="#usage">Usage</a> | |
201 <ol> | |
202 </ol> | |
203 </li> | |
204 <li> | |
205 <a href="#apiReference">API reference: chrome.experimental.keybi
nding</a> | |
206 <ol> | |
207 <li> | |
208 <a href="#global-events">Events</a> | |
209 <ol> | |
210 <li> | |
211 <a href="#event-onCommand">onCommand</a> | |
212 </li> | |
213 </ol> | |
214 </li> | |
215 </ol> | |
216 </li> | |
217 </ol> | |
218 </div> | |
219 <!-- /TABLE OF CONTENTS --> | 192 <!-- /TABLE OF CONTENTS --> |
220 <!-- Standard content lead-in for experimental API pages --> | 193 <!-- Standard content lead-in for experimental API pages --> |
221 <p id="classSummary"> | |
222 For information on how to use experimental APIs, see the <a href="expe
rimental.html">chrome.experimental.* APIs</a> page. | |
223 </p> | |
224 <!-- STATIC CONTENT PLACEHOLDER --> | 194 <!-- STATIC CONTENT PLACEHOLDER --> |
225 <div id="static"><!-- BEGIN AUTHORED CONTENT --> | 195 <div id="static"></div> |
226 <p> | |
227 The keybinding API allows you to add keyboard shortcuts that trigger actions in | |
228 your extension. An action can be opening the browser action or page action popup | |
229 or sending a command to the extension. | |
230 </p> | |
231 <h2 id="manifest">Manifest</h2> | |
232 <p> | |
233 In addition to the "experimental" permission you must declare the "keybinding" | |
234 permission in your extension's manifest to use this API and set manifest_version | |
235 to (at least) 2. | |
236 </p> | |
237 <pre>{ | |
238 "name": "My extension", | |
239 ... | |
240 <b> "permissions": [ | |
241 "experimental", | |
242 "keybinding", | |
243 ]</b>, | |
244 ... | |
245 }</pre> | |
246 <h2 id="usage">Usage</h2> | |
247 <p>The keybinding API allows you to define specific commands, and bind them to a | |
248 default key combination. Each command your extension accepts must be listed in | |
249 the manifest as an attribute of the 'commands' manifest key. Note: Combinations | |
250 that involve Ctrl+Alt are not permitted in order to avoid conflicts with the | |
251 AltGr key.</p> | |
252 <pre>{ | |
253 "name": "My extension", | |
254 ... | |
255 <b> "commands": { | |
256 "toggle-feature-foo": { | |
257 "suggested_key": { | |
258 "default": "Ctrl+Shift+Y", | |
259 "mac": "Command+Shift+Y" | |
260 }, | |
261 "description": "Toggle feature foo" | |
262 }, | |
263 "_execute_browser_action": { | |
264 "suggested_key": { | |
265 "windows": "Ctrl+Shift+Y", | |
266 "mac": "Command+Shift+Y", | |
267 "chromeos": "Ctrl+Shift+U", | |
268 "linux": "Ctrl+Shift+J" | |
269 } | |
270 }, | |
271 "_execute_page_action": { | |
272 "suggested_key": { | |
273 "default": "Ctrl+E" | |
274 "windows": "Alt+P", | |
275 "mac": "Option+P", | |
276 } | |
277 } | |
278 }</b>, | |
279 ... | |
280 }</pre> | |
281 <p>In your background page, you can bind a handler to each of the commands | |
282 defined in the manifest (except for '_execute_browser_action' and | |
283 '_execute_page_action') via onCommand.addListener. For example:</p> | |
284 <pre>chrome.experimental.keybinding.onCommand.addListener(function(command) { | |
285 console.log('Command:', command); | |
286 }); | |
287 </pre> | |
288 <p>The '_execute_browser_action' and '_execute_page_action' commands are | |
289 reserved for the action of opening your extension's popups. They won't normally | |
290 generate events that you can handle. If you need to take action based on your | |
291 popup opening, consider listening for an 'onDomReady' event inside your popup's | |
292 code. | |
293 </p> | |
294 <!-- END AUTHORED CONTENT --> | |
295 </div> | |
296 <!-- API PAGE --> | 196 <!-- API PAGE --> |
297 <div class="apiPage"> | 197 <!-- /apiPage --> |
298 <a name="apiReference"></a> | |
299 <h2>API reference: chrome.experimental.keybinding</h2> | |
300 <!-- PROPERTIES --> | |
301 <!-- /apiGroup --> | |
302 <!-- METHODS --> | |
303 <!-- /apiGroup --> | |
304 <!-- EVENTS --> | |
305 <div id="eventsTemplate" class="apiGroup"> | |
306 <a name="global-events"></a> | |
307 <h3>Events</h3> | |
308 <!-- iterates over all events --> | |
309 <div class="apiItem"> | |
310 <a name="event-onCommand"></a> | |
311 <h4>onCommand</h4> | |
312 <div class="summary"> | |
313 <!-- Note: intentionally longer 80 columns --> | |
314 <span class="subdued">chrome.experimental.keybinding.</span><spa
n>onCommand</span><span class="subdued">.addListener</span>(function(<span>strin
g command</span>) <span class="subdued">{...}</span><span></span>); | |
315 </div> | |
316 <div class="description"> | |
317 <p>Fired when a registered command is activated using a keyboard
shortcut.</p> | |
318 <!-- LISTENER PARAMETERS --> | |
319 <div> | |
320 <h4>Listener parameters</h4> | |
321 <dl> | |
322 <div> | |
323 <div> | |
324 <dt> | |
325 <var>command</var> | |
326 <em> | |
327 <!-- TYPE --> | |
328 <div style="display:inline"> | |
329 ( | |
330 <span id="typeTemplate"> | |
331 <span> | |
332 <span>string</span> | |
333 </span> | |
334 </span> | |
335 ) | |
336 </div> | |
337 </em> | |
338 </dt> | |
339 <dd class="todo"> | |
340 Undocumented. | |
341 </dd> | |
342 <!-- OBJECT PROPERTIES --> | |
343 <!-- OBJECT METHODS --> | |
344 <!-- OBJECT EVENT FIELDS --> | |
345 <!-- FUNCTION PARAMETERS --> | |
346 </div> | |
347 </div> | |
348 </dl> | |
349 </div> | |
350 <!-- EXTRA PARAMETERS --> | |
351 <!-- LISTENER RETURN VALUE --> | |
352 <dl> | |
353 </dl> | |
354 </div> <!-- /description --> | |
355 <!-- /description --> | |
356 </div> <!-- /apiItem --> | |
357 </div> <!-- /apiGroup --> | |
358 <!-- TYPES --> | |
359 <!-- /apiGroup --> | |
360 </div> <!-- /apiPage --> | |
361 </div> <!-- /gc-pagecontent --> | 198 </div> <!-- /gc-pagecontent --> |
362 </div> <!-- /g-section --> | 199 </div> <!-- /g-section --> |
363 </div> <!-- /codesiteContent --> | 200 </div> <!-- /codesiteContent --> |
364 <div id="gc-footer" --=""> | 201 <div id="gc-footer" --=""> |
365 <div class="text"> | 202 <div class="text"> |
366 <p> | 203 <p> |
367 Except as otherwise <a href="http://code.google.com/policies.html#restrictions
">noted</a>, | 204 Except as otherwise <a href="http://code.google.com/policies.html#restrictions
">noted</a>, |
368 the content of this page is licensed under the <a rel="license" href="http://c
reativecommons.org/licenses/by/3.0/">Creative Commons | 205 the content of this page is licensed under the <a rel="license" href="http://c
reativecommons.org/licenses/by/3.0/">Creative Commons |
369 Attribution 3.0 License</a>, and code samples are licensed under the | 206 Attribution 3.0 License</a>, and code samples are licensed under the |
370 <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD Lic
ense</a>. | 207 <a rel="license" href="http://code.google.com/google_bsd_license.html">BSD Lic
ense</a>. |
(...skipping 17 matching lines...) Expand all Loading... |
388 _uff=0; | 225 _uff=0; |
389 urchinTracker(); | 226 urchinTracker(); |
390 } | 227 } |
391 catch(e) {/* urchinTracker not available. */} | 228 catch(e) {/* urchinTracker not available. */} |
392 </script> | 229 </script> |
393 <!-- end analytics --> | 230 <!-- end analytics --> |
394 </div> | 231 </div> |
395 </div> <!-- /gc-footer --> | 232 </div> <!-- /gc-footer --> |
396 </div> <!-- /gc-container --> | 233 </div> <!-- /gc-container --> |
397 </body></html> | 234 </body></html> |
OLD | NEW |