Monday, 13 June 2016

Detecting Ctrl+ V Key Pressed Or Stroke Using C# & VB.Net In Windows Application

6/13/2016 - By Pranav Singh 5


This article will show you how you can detect the button combination pressed in windows application using c#.net in windows application. Here I will show an example of detecting or capturing ctrl+v button in windows application.

So for this article first we will create a new windows application and generate the KeyDown event. Add the below code into the event.

C#.Net
private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Control && e.KeyCode == Keys.V)
            {
                label1.Text = "You have pressed Ctrl+V";
            }
        }

VB.Net
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs)
    If e.Control AndAlso e.KeyCode = Keys.V Then
        label1.Text = "You have pressed Ctrl+V"
    End If
End Sub

Here in above code e.Control is for Ctrl Button and Keys.V for V button. So I have display the message as user press the specified button combination.

Now we have done run the application to check the output.


About the Author

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

5 comments:

  1. How to detect control+v even outside app

    ReplyDelete
    Replies
    1. Hi Natesh,
      What do you mean by even outside app. Please explain it more.
      Thanks

      Delete
    2. This will work when the form is maximised. you minimise it and press control+ v in notepad to paste something, this won't work

      Delete
    3. This will work when the form is maximised. you minimise it and press control+ v in notepad to paste something, this won't work

      Delete
    4. Hi Gokul,
      I got your point i will check and get back to you.

      Delete

Please let me know your view

Free Ebooks


About Us

We are the group of people who are expertise in different Microsoft technology like Asp.Net,MVC,C#.Net,VB.Net,Windows Application,WPF,jQuery,Javascript,HTML. This blog is designed to share the knowledge.

Contact Us

For writing article in this website please send request by your

GMAIL ID: dotnetpools@gmail.com

Bugs and Suggestions

As we all know that this website is for sharing knowledge and providing proper solution. So while reading the article is you find any bug or if you have any suggestion please mail us at contact@aspdotnet-pools.com.

Partners


Global Classified : Connectseekers.com
© 2014 aspdotnet-pools.com Designed by Bloggertheme9.
back to top