1
0
Fork 0
lazarus-tutorials/simple_examples/keypress.pas

24 lines
550 B
ObjectPascal
Raw Normal View History

2021-09-30 13:50:03 -04:00
program keypress;
{#mode objfpc}{$H+}
procedure KeyPress(Key: Char);
begin
2021-09-30 14:35:36 -04:00
case upCase(Key) of
'0'..'9': WriteLn('Key ''', Key, ''' is numeric');
'A', 'E', 'I', 'O', 'U': WriteLn('Key ''', Key, ''' is a vowel');
'B'..'D', 'F'..'H', 'J'..'N', 'P'..'T', 'V'..'Z':
WriteLn('Key ''', Key, ''' is a consonant');
else WriteLn('Key ''', Key, ''' is not alphanumeric');
end;
2021-09-30 13:50:03 -04:00
end;
2021-09-30 14:35:36 -04:00
2021-09-30 13:50:03 -04:00
var s: string;
begin
2021-09-30 14:35:36 -04:00
WriteLn('Press a key, then [Enter], (or [Enter] alone to finish)');
repeat
ReadLn(s);
if s <> '' then KeyPress(s[1]);
until s='';
2021-09-30 13:50:03 -04:00
end.