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

Unified Diff: Source/devtools/front_end/ExtensionAPI.js

Issue 18835002: DevTools extensions: forward keyboard shortcuts to DevTools (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/ExtensionAPI.js
diff --git a/Source/devtools/front_end/ExtensionAPI.js b/Source/devtools/front_end/ExtensionAPI.js
index 5577ddf41e9dea2557a6d960093e22799aa437cd..7b038c973e33a6ade4062b2167384789b1cedc0d 100644
--- a/Source/devtools/front_end/ExtensionAPI.js
+++ b/Source/devtools/front_end/ExtensionAPI.js
@@ -80,6 +80,7 @@ function defineCommonExtensionSymbols(apiPrivate)
CreateSidebarPane: "createSidebarPane",
CreateStatusBarButton: "createStatusBarButton",
EvaluateOnInspectedPage: "evaluateOnInspectedPage",
+ ForwardKeyboardEvent: "_forwardKeyboardEvent",
GetConsoleMessages: "getConsoleMessages",
GetHAR: "getHAR",
GetPageResources: "getPageResources",
@@ -724,6 +725,27 @@ function TimelineImpl()
this.onEventRecorded = new EventSink(events.TimelineEventRecorded);
}
+function forwardKeyboardEvent(event)
+{
+ const Esc = "U+001B";
+ // We only care about global hotkeys, not about random text
+ if (!event.ctrlKey && !event.altKey && !event.metaKey && !/^F\d+$/.test(event.keyIdentifier) && event.keyIdentifier != Esc)
apavlov 2013/07/09 06:51:59 !==
+ return;
+ var request = {
+ command: commands.ForwardKeyboardEvent,
+ eventType: event.type,
+ ctrlKey: event.ctrlKey,
+ altKey: event.altKey,
+ metaKey: event.metaKey,
+ keyIdentifier: event.keyIdentifier,
+ keyLocation: event.keyLocation
+ };
+ extensionServer.sendRequest(request);
+}
+
+document.addEventListener("keydown", forwardKeyboardEvent, false);
+document.addEventListener("keypress", forwardKeyboardEvent, false);
+
apavlov 2013/07/09 06:51:59 Would you want to forward "keyup" as well?
/**
* @constructor
*/

Powered by Google App Engine
This is Rietveld 408576698