Reputation: 93
I am trying to paste an image in TextBox on either user presses Ctrl + V shortcut or right-click and select paste option. I tried this method to capture the keyboard key but it only works if I enter V
if(e.Key == Windows.System.VirtualKey.V)
How to capture Ctrl + V both keyboard keys. In my case, this is not working
if (e.Key == Windows.System.VirtualKey.V && e.Key == Windows.System.VirtualKey.Control)
Upvotes: 0
Views: 550
Reputation:
In order to capture the control key, you need to check the HasFlag
property.
var controlDown = Window.Current.CoreWindow.GetKeyState(VirtualKey.Control).HasFlag(CoreVirtualKeyStates.Down);
if (controlDown & e.Key == Windows.System.VirtualKey.V)
{
}
Upvotes: 2