From 17d1b817145d24b7e0114b74a041e36e357ccace Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Thu, 30 Sep 2021 13:50:03 -0400 Subject: [PATCH] Add keypress example --- simple_examples/keypress.pas | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/simple_examples/keypress.pas b/simple_examples/keypress.pas index e69de29..388dcbb 100644 --- a/simple_examples/keypress.pas +++ b/simple_examples/keypress.pas @@ -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. \ No newline at end of file