本文整理汇总了C#中System.Windows.Input.KeyEventArgs.GetModifiers方法的典型用法代码示例。如果您正苦于以下问题:C# KeyEventArgs.GetModifiers方法的具体用法?C# KeyEventArgs.GetModifiers怎么用?C# KeyEventArgs.GetModifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Input.KeyEventArgs
的用法示例。
在下文中一共展示了KeyEventArgs.GetModifiers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPreviewKey
private void OnPreviewKey(KeyEventArgs e)
{
// As KeyDown and KeyUp bubble, it appears they're being handled before they get a chance to
// trigger the appropriate WM_ messages handled by our SourceHook, so we have to handle these extra keys here.
// Hooking the Tab key like this makes the tab focusing in essence work like
// KeyboardNavigation.TabNavigation="Cycle"; you will never be able to Tab out of the web browser control.
// We also add the condition to allow ctrl+a to work when the web browser control is put inside listbox.
if (e.Key == Key.Tab || e.Key == Key.Home || e.Key == Key.End || e.Key == Key.Up
|| e.Key == Key.Down || e.Key == Key.Left || e.Key == Key.Right
|| (e.Key == Key.A && Keyboard.Modifiers == ModifierKeys.Control))
{
var modifiers = e.GetModifiers();
var message = (int)(e.IsDown ? WM.KEYDOWN : WM.KEYUP);
var virtualKey = KeyInterop.VirtualKeyFromKey(e.Key);
e.Handled = managedCefBrowserAdapter.SendKeyEvent(message, virtualKey, (int)modifiers);
}
}