Board index » delphi » keyboard access

keyboard access

how can I find out whether a key has been released
the following ..

program testkbd;
uses crt;

procedure WaitForKeyUp;
begin
  repeat
    while keypressed do readkey;
  until not keypressed;
end;

begin
  ClrScr;
  Write('key is down');
  repeat until keypressed;
  WaitForKeyUp;
  Write('key is up');
  readln;
end.

.. returns immidiately from the
WaitForKeyUp procedure even if the key is still
pressed. I think i have to access the keyboard port
directly, but I don't have it's adress. How can I
fix the problem using

repeat until Port[???] = ???

thanks in advance

Peter

 

Re:keyboard access


On 24 Jan 1998 20:10:31 GMT, Peter.Rothf...@t-online.de (Peter

Quote
Rothfels) wrote:

Try this code,
var done:integer;
begin
done:=0;
  ClrScr;
  repeat
  if keypressed then begin while keypressed do begin write('Key is
UP'); readkey; end; end;
  writeln('Key is DOWN');
  until done=1;
end.

Quote
>.. returns immidiately from the
>WaitForKeyUp procedure even if the key is still
>pressed. I think i have to access the keyboard port
>directly, but I don't have it's adress. How can I
>fix the problem using

>repeat until Port[???] = ???

>thanks in advance

>Peter

        I don't know of any port through which we can detect keyboard
events, but you might want to try installing your own Keyboard
interrupt, which would be a more efficient way of trapping keyboard
events. Unfortunatly this means mapping every key. The interrupt you
need to hook into is 0x09

Cheers,
Amit
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
Amit Chattopadhyay (am...@technologist.com)
India, Chennai

-> The Online Community of the Net! - http://www.talkcity.com
-> An Idle Computer is a waste of resources! -> http://www.distributed.net/des.
*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
ICQ UIN: #6472448 .. RC5-64/DES Team: #1524
PGP Fingerprint: CC48 058F D51A 8C8D 568D  B327 3C80 3A4A E984 F614
PGP Public Key: http://pgp.ai.mit.edu:11371/pks/lookup?op=get&search=0xE984F614

Re:keyboard access


Quote
Peter Rothfels wrote:
> how can I find out whether a key has been released
> the following ..
> [snip!]

You don't.  The BIOS-level calls don't provide that sort of information.

Quote
> .. returns immidiately from the
> WaitForKeyUp procedure even if the key is still
> pressed. I think i have to access the keyboard port
> directly, but I don't have it's adress. How can I
> fix the problem using

> repeat until Port[???] = ???

Take a look at:

http://www.netcom.com/~setech/download/mkeys12.zip

Quote
> thanks in advance

> Peter

--
Scott Earnest            | SPAM protection in effect. Remove  |
setech@_ix.netcom.com    | "_" as needed for true addresses.  |
earnests@_homenet.lm.com |    UIN:1136443  EFnet:pale_blue    |
sinykal@_{*word*104}space.org  | URL: http://www.netcom.com/~setech |

Other Threads