• Martes 30 de Abril de 2024, 03:02

Autor Tema:  Leer Pulsaciones De Teclado  (Leído 1629 veces)

Hettar

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Leer Pulsaciones De Teclado
« en: Martes 11 de Mayo de 2004, 19:03 »
0
Alguien sabe como puedo hacer para q al pulsar los cursores en el teclado les pueda asignar eventos??

Pero leerlas al pulsar...algun procedure tipo readkey del Pascal

BlackTigerX

  • Miembro activo
  • **
  • Mensajes: 92
    • Ver Perfil
Re: Leer Pulsaciones De Teclado
« Respuesta #1 en: Jueves 27 de Mayo de 2004, 15:33 »
0
checate los eventos OnKeyDown, OnKeyPress de tu forma... ahi puedes hacer cualquier cosa cuando se presione cualquier tecla
BlackTigerX

Amilius

  • Miembro HIPER activo
  • ****
  • Mensajes: 665
    • Ver Perfil
Re: Leer Pulsaciones De Teclado
« Respuesta #2 en: Domingo 30 de Mayo de 2004, 23:14 »
0
Mejor si colocas al form en propiedades keypreview=true y usas los eventos:
OnKeyDown, OnKeyPress , Onkeyup, etc.

Puede ser un poco desorientador trabajar con una interfaz orientada a eventos si usaste antes Pascal en compiladores antiguos, pero ya te acostumbrarás y verás las ventajas.

Otra opción, un tanto no recomendable, es tener un ciclo y revisar el estado de las teclas con:

GetKeyState(VkKeyScan('a'))

Y no te olvides de incluir en el ciclo el "application.ProcessMessages;" o se quedará todo "trabado".

---------------

The GetKeyState function retrieves the status of the specified virtual key. The status specifies whether the key is up, down, or toggled (on, off ¾ alternating each time the key is pressed).

SHORT GetKeyState(

    int  nVirtKey    // virtual-key code
   );

Return Value

If the function succeeds, the return value specifies the status of the given virtual key. If the high-order bit is 1, the key is down; otherwise, it is up. If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.

----------

The VkKeyScan function translates a character to the corresponding virtual-key code and shift state for the current keyboard.

SHORT VkKeyScan(

    TCHAR  ch    // character to translate
   );