Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

188
Vistas
Get what key is pressed without event or pausing the application

I need to get the input from the user without pausing the application or having an event. Is there any way that I can get it without events and pausing? Since I have a timer that does other actions and I don't want to add events becuase that will result in messy code. So is there any way to get the key pressed without pausing the app or event?

Thanks.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You could use the User32 API function GetKeyState which allows you to query if a key is pressed. By doing so, you wouldn't need to handle events (or hooks) separately but could do it directly in your timer method.

    [DllImport("user32")]
    public static extern short GetKeyState(int nVirtKey);

This documentation goes into more detail: https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getkeystate

Edit: Here is an example of a method using that:

    public static bool LeftCtrlDown()
    {
        return (User32API.GetKeyState(User32API.VK_LCONTROL) & 0x8000) == 0x8000;
    }
over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda