|
-
Mar 27th, 2011, 02:04 AM
#1
Thread Starter
Hyperactive Member
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?
I am using .NET 2010 with Windows 7
-
Mar 27th, 2011, 04:07 AM
#2
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
-
Mar 27th, 2011, 04:13 AM
#3
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.
-
Mar 27th, 2011, 06:24 AM
#4
New Member
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.
-
Mar 27th, 2011, 06:43 AM
#5
Re: Detect Shift + Arrow key in form keydown event in BLANK form
 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.
-
Mar 28th, 2011, 12:14 AM
#6
Thread Starter
Hyperactive Member
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 :-)
I am using .NET 2010 with Windows 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|