in src/Calculator/Common/KeyboardShortcuManager.cs [638:708]
private static void OnKeyDownHandler(CoreWindow sender, KeyEventArgs args)
{
if (args.Handled)
{
return;
}
var key = args.VirtualKey;
int viewId = Utilities.GetWindowId();
bool isControlKeyPressed = (Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Control) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
bool isShiftKeyPressed = (Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Shift) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
bool isAltKeyPressed = (Window.Current.CoreWindow.GetKeyState(Windows.System.VirtualKey.Menu) & CoreVirtualKeyStates.Down) == CoreVirtualKeyStates.Down;
// Handle Ctrl + E for DateCalculator
if ((key == Windows.System.VirtualKey.E) && isControlKeyPressed && !isShiftKeyPressed && !isAltKeyPressed)
{
NavigateModeByShortcut(isControlKeyPressed, isShiftKeyPressed, false, key, ViewMode.Date);
return;
}
if (s_ignoreNextEscape.TryGetValue(viewId, out var currentIgnoreNextEscape))
{
if (currentIgnoreNextEscape && key == Windows.System.VirtualKey.Escape)
{
if (s_keepIgnoringEscape.TryGetValue(viewId, out var currentKeepIgnoringEscape))
{
if (!currentKeepIgnoringEscape)
{
HonorEscape();
}
return;
}
}
}
if (s_fHonorShortcuts.TryGetValue(viewId, out var currentHonorShortcuts))
{
if (currentHonorShortcuts)
{
var myVirtualKey = key;
var lookupMap = GetCurrentKeyDictionary(isControlKeyPressed, isShiftKeyPressed, isAltKeyPressed);
if (lookupMap == null)
{
return;
}
var buttons = EqualRange(lookupMap, (MyVirtualKey)myVirtualKey);
if (buttons.Count() <= 0)
{
return;
}
KeyboardShortcutManagerLocals.RunFirstEnabledButtonCommand(buttons);
// Ctrl+C and Ctrl+V shifts focus to some button because of which enter doesn't work after copy/paste. So don't shift focus if Ctrl+C or Ctrl+V
// is pressed. When drop down is open, pressing escape shifts focus to clear button. So dont's shift focus if drop down is open. Ctrl+Insert is
// equivalent to Ctrl+C and Shift+Insert is equivalent to Ctrl+V
//var currentIsDropDownOpen = s_IsDropDownOpen.find(viewId);
if (!s_IsDropDownOpen.TryGetValue(viewId, out var currentIsDropDownOpen) || !currentIsDropDownOpen)
{
// Do not Light Up Buttons when Ctrl+C, Ctrl+V, Ctrl+Insert or Shift+Insert is pressed
if (!(isControlKeyPressed && (key == Windows.System.VirtualKey.C || key == Windows.System.VirtualKey.V || key == Windows.System.VirtualKey.Insert))
& !(isShiftKeyPressed && (key == Windows.System.VirtualKey.Insert)))
{
KeyboardShortcutManagerLocals.LightUpButtons(buttons);
}
}
}
}
}