1
0
Fork 0

Add keypress example

This commit is contained in:
Timothy Warren 2021-09-30 13:50:03 -04:00
parent f8eb36a4e0
commit 17d1b81714
1 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,24 @@
program keypress;
{#mode objfpc}{$H+}
procedure KeyPress(Key: Char);
begin
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;
end;
var s: string;
begin
WriteLn('Press a key, then [Enter], (or [Enter] alone to finish)');
repeat
ReadLn(s);
if s <> '' then KeyPress(s[1]);
until s='';
end.