Many thanks; yes that's exactly what I want.
So I use the Form1.FormKeyPress to get the ascii values of the Keypress
and the FormKeyUp to catch the other values from the F-Keys, etc?
Gerald Pöttler wrote:
Not sure what you are trying to achieve, but there is not always a
ASCII code for every key: try the following on a form with a memo field:
you will see that pressing 'A' and shift + 'A' will give you two
different character codes, but the same key code, whereas F1 will not
give you a character code. Escape however does gives you the same
keycode and character code, whereas the tilde (~) gives you two very
different codes. Hope this helps.
procedure TForm1.FormCreate(Sender: TObject);
begin
KeyPreview:=true;
end;
procedure TForm1.FormKeyPress(Sender: TObject; var Key: char);
begin
memo1.lines.add('Read Character '+inttostr(ord(key)));
end;
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift:
TShiftState);
begin
memo1.lines.add('Read KEY CODE '+inttostr(key));
end;
On 2/25/07, *Dave Coventry* <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>> wrote:
Hi,
I'm using a Tmemo onKeyUp event to catch keyboard input (I need to
catch
function keys as well).
Is there a simple way to get the ascii value of a key pressed
using this
event?
For example, if the user types a '(', then key=57 which is ascii
for '9'.
I know that I can test the shift variable to tell if the shift key is
pressed and process the input from that, but it's a bit of a pain and
I'm worried about different keyboard layouts.
--
Dave Coventry
Tel (home): +27(0)31 3092301
Tel (office): +27(0)31 3092301
Cell: +27(0)82 3685983
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives
--
Gerald Pöttler
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
--
Dave Coventry
Tel (home): +27(0)31 3092301
Tel (office): +27(0)31 3092301
Cell: +27(0)82 3685983
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives