本文整理匯總了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);
}
}