Support invoking key shortcuts using Control.
This enables Select All, Cut, Copy and Paste behavior in TextViews
and provides a general pattern for implementing additional keyboard
accelerators based on Control key shortcuts. The same shortcuts
also apply to menu accelerators.
Bug: 3286262
Change-Id: I7d458ee26abf51e0de1735ce490ce3baf504b471
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 281dd27..5d81702 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -2626,6 +2626,16 @@
return;
}
+ // If the Control modifier is held, try to interpret the key as a shortcut.
+ if (event.getAction() == KeyEvent.ACTION_UP
+ && event.isCtrlPressed()
+ && !KeyEvent.isModifierKey(event.getKeyCode())) {
+ if (mView.dispatchKeyShortcutEvent(event)) {
+ finishKeyEvent(event, sendDone, true);
+ return;
+ }
+ }
+
// Apply the fallback event policy.
if (mFallbackEventHandler.dispatchKeyEvent(event)) {
finishKeyEvent(event, sendDone, true);