Detect Shift + Arrow key in form keydown event in BLANK form
Hi guys,
Due to some weird requirement, I need to detect shift + arrow key in blank form. But it's not working. I also tried overriding IsInputKey method but it only detects single key press (like arrow key) but when multiple key are pressed it simply doesn't work.
Is there any workaround?
Re: Detect Shift + Arrow key in form keydown event in BLANK form
Hi,
You can try it like this;
vb Code:
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If e.Shift And e.KeyCode = Keys.Up Then
MsgBox("You pressed Shift and Arrowkey up")
End If
End Sub
Re: Detect Shift + Arrow key in form keydown event in BLANK form
Follow the Blog link in my signature and check out my post on keyboard events.
Re: Detect Shift + Arrow key in form keydown event in BLANK form
If e.keycode=keys.right then
if e.keycode=keys.shift then
(Code goes here)
end if
end if
I'm writing this from memory, so don't hate on me if it doesn't work.
Re: Detect Shift + Arrow key in form keydown event in BLANK form
Quote:
Originally Posted by
Exiled
If e.keycode=keys.right then
if e.keycode=keys.shift then
(Code goes here)
end if
end if
I'm writing this from memory, so don't hate on me if it doesn't work.
It won't work. You've got two nested If statements and they are both testing e.KeyCode but for different values. e.KeyCode can never have two different values at the same time, so the contents of the inner If block can never be executed.
My blog post explains how to test for key combinations that include specific modifiers.
Re: Detect Shift + Arrow key in form keydown event in BLANK form
Hi jmcilhinney,
Very nice blog regarding key events. But it didn't solved the problem in blank form. Surely, it worked when I dropped textbox in form. Anyway, I solved the issue with IMessageFilter interface. I hope you write blog regarding IMessageFilter someday. It would be very helpful.
Thanks all for help :-)