Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6122097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:51:33+00:00 2026-05-23T15:51:33+00:00

How do I make hotkeys for buttons, which will activate it, like I pressed

  • 0

How do I make hotkeys for buttons, which will activate it, like I pressed the button?

Keep in mind I’m new at programming.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:51:34+00:00Added an answer on May 23, 2026 at 3:51 pm

    You can use the GetKeyState function in Windows. Windows functions must be referenced by APIs, since they are not by default included in the .NET Framework as such.

    Assuming you only need to detect one keystroke, GetKeyState or GetAsyncKeyState would probably be best for that. GetKeyState will wait until a specific key is pressed and then get the state of that key, and GetAsyncKeyState will get the state of a key at the time the function is called.

    The declaration of GetKeyState is as follows:

    <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
    Public Shared Function GetKeyState(ByVal virtualKeyCode As Integer) As Short
    End Function
    

    Put that inside the class where you wish to use the function.

    The virtualKeyCode argument of the function is the keycode of the key you are trying to get the state of. You can see a list of all the virtual keycodes here: http://msdn.microsoft.com/en-us/library/ms927178.aspx

    The GetAsyncKeyState declaration is almost the same as the GetKeyState declaration.

    <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)> _
    Public Shared Function GetAsyncKeyState(ByVal virtualKeyCode As Integer) As Short
    End Function
    

    Using both the GetKeyState and GetAsyncKeyState is pretty simple From Microsoft’s own documentation (http://msdn.microsoft.com/en-us/library/ms646293(v=vs.85).aspx) it says:

    If the function succeeds, the return value specifies whether the key was pressed since the last call to GetAsyncKeyState, and whether the key is currently up or down. If the most significant bit is set, the key is down, and if the least significant bit is set, the key was pressed after the previous call to GetAsyncKeyState. However, you should not rely on this last behavior; for more information, see the Remarks.

    Given the above information, here’s an example of GetAsyncKeyState usage:

    Dim X As Integer = GetAsyncKeyState(KeyCodeHere)
    If X = 1 Or X = -32767 Then
        'your keycode was pressed or released.
    End If
    

    If you need to get notified when the user presses any kind of key, a keyboard hook would be more appropriate.

    Lastly, you may also use the RegisterHotkey API to get notified by Windows when specific hotkeys are pressed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

With make on linux, we can do things like: foo=$(shell /bin/bar) which runs the
Make a new AS3 Document in Flash, paste in the following code and run
make is not only useful for building your programming project, but it seems to
To make a JavaScript class with a public method I'd do something like: function
Make something like in html/css
How make activate cluetip on event ready or onload? The clueTip plugin allows you
begin # make a new outgoing call @call = @client.account.calls.create( :from => '+1*********', :to
I make services folder in my Zend project and i create new php file
To make it short: hibernate doesn't support projections and query by example? I found
To make things easier when switching between machines (my workstation at the office and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.