Ver Mensaje Individual
  #7  
Antiguo 29-10-2010
rrf rrf is offline
Miembro
 
Registrado: ago 2003
Ubicación: S/C Tenerife, España
Posts: 454
Reputación: 21
rrf Va por buen camino
Smile

Ecfisa, me has adelantado mientras preparaba la respuesta a mi propia pregunta.

Aquí está el código que preparé. El tuyo es más sencillo y claro; pero ya que lo hice, lo incluyo:

Código Delphi [-]
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin

      //  Teclas combinadas: en los EVENTOS OnKeyDown y OnKeyUp
      //---------------------------------------------------------

   if ( Shift = [ ssctrl ] )                                      // CTRL + S
      and ( ( ord ( Key ) = 83 ) or ( ord ( Key ) = 115 ) )      // CTRL + s
    then
      Label1.Caption := 'ctrl + s'

  else if ( Shift = [ ssAlt, ssctrl ] )                          // CTRL + ALT + j
      and ( ( ord ( Key ) = 106 ) or ( ord ( Key ) = 74 ) )      // CTRL + ALT + J
    then
      Label1.Caption := 'ctrl + alt + j'

  else if ( Shift = [ ssAlt ] )                                  // ALT + M
      and ( ( ord ( Key ) = 77 ) or ( ord ( Key ) = 109 ) )      // ALT + m
    then
      Label1.Caption := 'alt + m'' ;

end;

Desconocía la función "lo", que hace que la solución que tú aportaste sea más sencilla.

Bueno, si se quiere conocer el código Ascii de una letra o caracter sin consultar las tablas, con esta línea, se podrá ver el caracter y el código que le corresponde.

Código Delphi [-]
procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin

  Label2.Caption := key + ' = ' + inttostr ( ord ( key ) ) ;

end;

Ojo, que está en el procedimiento FormKeyPress.

Gracias Ecfisa.

Saludos
Responder Con Cita