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

  • Home
  • SEARCH
  • 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 561411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:26:50+00:00 2026-05-13T12:26:50+00:00

I want to able to hold a key down while the application is loading

  • 0

I want to able to hold a key down while the application is loading and depending on which is being held down a certain form is shown.

For example holding down shift and the opening itunes opens a little dialog allowing you set the library(or something)

I can check whether the shift/Ctrl/Alt are being held down but i’d prefer to use the letters/digits.

Such as hold 1 down to open Form1 and hold 2 down to open form 2.

  • 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-13T12:26:50+00:00Added an answer on May 13, 2026 at 12:26 pm

    If you’re wanting to do this on traditional winforms, you can check out this article:

    http://www.switchonthecode.com/tutorials/winforms-accessing-mouse-and-keyboard-state

    About half-way down there’s an abstract Keyboard class that uses a system call to get key states. You might want to give it a try.

    EDIT: Here’s that class converted to VB.NET. I haven’t tested it so there might be some errors. Let me know.

    Imports System
    Imports System.Windows.Forms
    Imports System.Runtime.InteropServices
    
    Public MustInherit Class Keyboard
    
        <Flags()>
        Private Enum KeyStates
            None = 0
            Down = 1
            Toggled = 2
        End Enum
    
        <DllImport("user32.dll", CharSet:=CharSet.Auto, ExactSpelling:=True)>
        Private Shared Function GetKeyState(ByVal keyCode As Integer) As Short
        End Function
    
        Private Shared Function GetKeyState(ByVal key As Keys) As KeyStates
            Dim state = KeyStates.None
    
            Dim retVal = GetKeyState(CType(key, Integer))
    
            ' if the high-order bit is 1, the key is down
            ' otherwise, it is up
            If retVal And &H8000 = &H8000 Then
                state = state Or KeyStates.Down
            End If
    
            ' If the low-order bit is 1, the key is toggled.
            If retVal And 1 = 1 Then
                state = state Or KeyStates.Toggled
            End If
    
            Return state
        End Function
    
        Public Shared Function IsKeyDown(ByVal key As Keys) As Boolean
            Return KeyStates.Down = (GetKeyState(key) And KeyStates.Down)
        End Function
    
        Public Shared Function IsKeyToggled(ByVal key As Keys) As Boolean
            Return KeyStates.Toggled = (GetKeyState(key) And KeyStates.Toggled)
        End Function
    
    End Class
    

    So once you add this class to your project, you can do something like this:

    ' See if the 1 button is being held down
    If Keyboard.IsKeyDown(Keys.D1) Then
        ' Do the form showing stuff here
    EndIf
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 357k
  • Answers 357k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You probably want to call setlocale() first, "LC_ALL" should do… May 14, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Linux Ubuntu Desktop Jaunty Firebug FireCookie Pixel Perfect Web developer… May 14, 2026 at 9:06 am
  • Editorial Team
    Editorial Team added an answer Your code should look like this: var par = [];… May 14, 2026 at 9:06 am

Related Questions

Background: I have an application where I want to be able to capture keyboard
I have a Windows form which does not have a border, titlebar, menu, etc..
suppose that I have this RDBM table ( Entity-attribute-value_model ): col1: entityID col2: attributeName
I want to be able to use a plist for settings Im implementing in
I'm writing a very simple blog engine for own use (since every blog engine

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.