Reconnaissance de touches

Résolu
eole15 Messages postés 12 Date d'inscription lundi 29 décembre 2008 Statut Membre Dernière intervention 18 février 2009 - 5 janv. 2009 à 15:20
offlake Messages postés 190 Date d'inscription mercredi 3 septembre 2008 Statut Membre Dernière intervention 17 janvier 2009 - 7 janv. 2009 à 07:33
Bonjour a tous, je developpe un jeu sous delphi.Net mais voila j'ai un probleme je n'arrive pas a faire que mon programme sache sur quel touche du clavier j'appui....
Si quelqu'un pouvais m'aider jen serais heureux.
Merci d'avance.

EoLe15

1 réponse

offlake Messages postés 190 Date d'inscription mercredi 3 septembre 2008 Statut Membre Dernière intervention 17 janvier 2009
7 janv. 2009 à 07:33
Pour la Reconnaissance des touches C'est Simple
Voilà un Exemple qui montre comment la reconnaissance des Touches !!

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
// Alphabet

// a/A
if key = #97 then
Label1.Caption := 'You Pressed '+'a';
if key = #65 then
Label1.Caption := 'You Pressed '+'A';

// b/B
if key = #98 then
Label1.Caption := 'You Pressed '+'b';
if key = #66 then
Label1.Caption := 'You Pressed '+'B';

// c/C
if key = #99 then
Label1.Caption := 'You Pressed '+'c';
if key = #67 then
Label1.Caption := 'You Pressed '+'C';

// d/D
if key = #100 then
Label1.Caption := 'You Pressed '+'d';
if key = #68 then
Label1.Caption := 'You Pressed '+'D';

// e/E
if key = #101 then
Label1.Caption := 'You Pressed '+'e';
if key = #69 then
Label1.Caption := 'You Pressed '+'E';

// f/F
if key = #102 then
Label1.Caption := 'You Pressed '+'f';
if key = #70 then
Label1.Caption := 'You Pressed '+'F';

// g/G
if key = #103 then
Label1.Caption := 'You Pressed '+'g';
if key = #71 then
Label1.Caption := 'You Pressed '+'G';

// h/H
if key = #104 then
Label1.Caption := 'You Pressed '+'h';
if key = #72 then
Label1.Caption := 'You Pressed '+'H';

// i/I
if key = #105 then
Label1.Caption := 'You Pressed '+'i';
if key = #73 then
Label1.Caption := 'You Pressed '+'I';

// j/J
if key = #106 then
Label1.Caption := 'You Pressed '+'j';
if key = #74 then
Label1.Caption := 'You Pressed '+'J';

// k/K
if key = #107 then
Label1.Caption := 'You Pressed '+'k';
if key = #75 then
Label1.Caption := 'You Pressed '+'K';

// l/L
if key = #108 then
Label1.Caption := 'You Pressed '+'l';
if key = #76 then
Label1.Caption := 'You Pressed '+'L';

// m/M
if key = #109 then
Label1.Caption := 'You Pressed '+'m';
if key = #77 then
Label1.Caption := 'You Pressed '+'M';

// n/N
if key = #110 then
Label1.Caption := 'You Pressed '+'n';
if key = #78 then
Label1.Caption := 'You Pressed '+'N';

// o/O
if key = #111 then
Label1.Caption := 'You Pressed '+'o';
if key = #79 then
Label1.Caption := 'You Pressed '+'O';

// p/P
if key = #112 then
Label1.Caption := 'You Pressed '+'p';
if key = #80 then
Label1.Caption := 'You Pressed '+'P';

// q/Q
if key = #113 then
Label1.Caption := 'You Pressed '+'q';
if key = #81 then
Label1.Caption := 'You Pressed '+'Q';

// r/R
if key = #114 then
Label1.Caption := 'You Pressed '+'r';
if key = #82 then
Label1.Caption := 'You Pressed '+'R';

// s/S
if key = #115 then
Label1.Caption := 'You Pressed '+'s';
if key = #83 then
Label1.Caption := 'You Pressed '+'S';

// t/T
if key = #116 then
Label1.Caption := 'You Pressed '+'t';
if key = #84 then
Label1.Caption := 'You Pressed '+'T';

// u/U
if key = #117 then
Label1.Caption := 'You Pressed '+'u';
if key = #85 then
Label1.Caption := 'You Pressed '+'U';

// v/V
if key = #118 then
Label1.Caption := 'You Pressed '+'v';
if key = #86 then
Label1.Caption := 'You Pressed '+'V';

// w/W
if key = #119 then
Label1.Caption := 'You Pressed '+'w';
if key = #87 then
Label1.Caption := 'You Pressed '+'W';

// x/X
if key = #120 then
Label1.Caption := 'You Pressed '+'x';
if key = #88 then
Label1.Caption := 'You Pressed '+'X';

// y/Y
if key = #121 then
Label1.Caption := 'You Pressed '+'y';
if key = #89 then
Label1.Caption := 'You Pressed '+'Y';

// z/Z
if key = #122 then
Label1.Caption := 'You Pressed '+'z';
if key = #90 then
Label1.Caption := 'You Pressed '+'Z';

// end Alphabet

// Numbers

// 0
if key = #48 then
Label1.Caption := 'You Pressed '+'0';

// 1
if key = #49 then
Label1.Caption := 'You Pressed '+'1';

// 2
if key = #50 then
Label1.Caption := 'You Pressed '+'2';

// 3
if key = #51 then
Label1.Caption := 'You Pressed '+'3';

// 4
if key = #52 then
Label1.Caption := 'You Pressed '+'4';

// 5
if key = #53 then
Label1.Caption := 'You Pressed '+'5';

// 6
if key = #54 then
Label1.Caption := 'You Pressed '+'6';

// 7
if key = #55 then
Label1.Caption := 'You Pressed '+'7';

// 8
if key = #56 then
Label1.Caption := 'You Pressed '+'8';

// 9
if key = #57 then
Label1.Caption := 'You Pressed '+'9';

// end numbers

// Misc

// Space
if key = #32 then
Label1.Caption := 'You Pressed '+'Space';

// !
if key = #33 then
Label1.Caption := 'You Pressed '+'!';

// "
if key = #34 then
Label1.Caption := 'You Pressed '+'"';

// #
if key = #35 then
Label1.Caption := 'You Pressed '+'#';

// $
if key = #36 then
Label1.Caption := 'You Pressed '+'$';

// %
if key = #37 then
Label1.Caption := 'You Pressed '+'%';

// &
if key = #38 then
Label1.Caption := 'You Pressed '+'amp';

// '
if key = #39 then
Label1.Caption := 'You Pressed '+'N/A';

// (
if key = #40 then
Label1.Caption := 'You Pressed '+'(';

// )
if key = #41 then
Label1.Caption := 'You Pressed '+')';

// *
if key = #42 then
Label1.Caption := 'You Pressed '+'*';

// +
if key = #43 then
Label1.Caption := 'You Pressed '+'+';

// ,
if key = #44 then
Label1.Caption := 'You Pressed '+',';

// -
if key = #45 then
Label1.Caption := 'You Pressed '+'-';

// .
if key = #46 then
Label1.Caption := 'You Pressed '+'.';

// /
if key = #47 then
Label1.Caption := 'You Pressed '+'/';

// :
if key = #58 then
Label1.Caption := 'You Pressed '+':';

// ;
if key = #59 then
Label1.Caption := 'You Pressed '+';';

// <
if key = #60 then
Label1.Caption := 'You Pressed '+'<';
// if key #61 then
Label1.Caption := 'You Pressed '+'=';

// >
if key = #62 then
Label1.Caption := 'You Pressed '+'>';

// ?
if key = #63 then
Label1.Caption := 'You Pressed '+'?';

// @
if key = #64 then
Label1.Caption := 'You Pressed '+'@';

// [
if key = #91 then
Label1.Caption := 'You Pressed '+'[';

// \
if key = #92 then
Label1.Caption := 'You Pressed '+'\';

// ]
if key = #93 then
Label1.Caption := 'You Pressed '+']';

// ^
if key = #94 then
Label1.Caption := 'You Pressed '+'^';

// _
if key = #95 then
Label1.Caption := 'You Pressed '+'_';

// `
if key = #96 then
Label1.Caption := 'You Pressed '+'`';

// {
if key = #123 then
Label1.Caption := 'You Pressed '+'{';

// |
if key = #124 then
Label1.Caption := 'You Pressed '+'|';

// }
if key = #125 then
Label1.Caption := 'You Pressed '+'}';

// ~
if key = #126 then
Label1.Caption := 'You Pressed '+'~';

// Backspace
if key = #8 then
Label1.Caption := 'You Pressed '+'Backspace';

// ECHAPE
if key = #27 then
Label1.Caption := 'You Pressed '+'Escape';

// EntRER
if key = #13 then
Label1.Caption := 'You Pressed '+'Enter';
end;

BY OFFLAKE
-2
Rejoignez-nous