SRL Archive - Suggestions

function ReadKey: char;


Baked0420

2010-08-22 15:55:24

I can't find a way to get which key is pressed returned. Google showed ReadKey which returns a char. I saw a script online like:


var
x: Integer;
key: char;
begin
key:= ReadKey;
case key of
'a': exit;
'b': Inc(x);
end;
end.

wasn't that exactly, but that's what they were doing basically. Could you add ReadKey, or if it's in there already what's it called?

Dervish

2010-08-22 16:29:53

if(iskeydown(…)) then ?

Baked0420

2010-08-22 16:51:57

but I wanna get any key that is pressed, then be able to go different ways depending on which is pressed, I figured ReadKey would be more practical then:


var
a, b, c: Integer;
begin
repeat
if(IsKeyDown('a'))then
begin
Inc(a);
writeln('a');
end
else if(IsKeyDown('b'))then
begin
Inc(b);
writeln('b');
end
else if(IsKeyDown('c'))then
begin
Inc(c);
writeln('c');
end;
wait(100);
Until(IsFKeyDown(2));
writeln('a: ' + IntToStr(a) + chr(13) + 'b: ' + IntToStr(b) + chr(13) + 'c: ' + IntToStr(c));
end.


case Key of
'a': Inc(a);
'b': Inc(b);
'c': Inc(c);
end;
writeln(key);

would be much easier.

nielsie95

2010-08-22 17:05:38

I think ReadKey is for console applications.

3Garrett3

2010-08-22 17:06:41

From: nielsie95
I think ReadKey is for console applications.


Could we make/use a function that is similar to it though?

nielsie95

2010-08-22 17:14:39

ReadKey is just the single key version of ReadLn (something like InputQuery). (Remember those messages like "Press any key to continue"?)

It is possible to hook the keyboard so that you can handle every key press, but it will be hard to integrate such a thing into a script.

EvilChicken!

2010-08-22 17:38:30

Didn't Ron have a SCAR keylogger?

nielsie95

2010-08-22 17:41:44

http://villavu.com/forum/showthread.php?t=3197

It uses IsKeyDown a lot ;)