Board index » delphi » Detecting when a key has been released

Detecting when a key has been released

Hi,
I'm using Turbo Pascal 7.0
I would like to know if there is a way to detect that a key has been
released.

--
---------------------
Hensley Bass
Email Address: hb...@intnet.mu
Home Page: http://pages.intnet.mu/jhbpage
----------------------------------------------------------------

-

 

Re:Detecting when a key has been released


Hi!

There is a unit "keylib" included in my GX2 package, available
on my page: www.crossfire-designs.de
This one allows to do almost everything with the keyboard.
If you don't wanna download the whole package (1.2 M), ask
me via mail to send it to you.

Bye,
Stefan
---
    ***   -- Stefan G?hler, Germany      --
  ** * ** -- Crossfire Designs           --
    ***   -- http://crossfire-designs.de --

"Hensley Bass" <hb...@intnet.mu> schrieb im Newsbeitrag news:aamm54$u3l$2@news.intnet.mu...

Quote
> Hi,
> I'm using Turbo Pascal 7.0
> I would like to know if there is a way to detect that a key has been
> released.

> --
> ---------------------
> Hensley Bass
> Email Address: hb...@intnet.mu
> Home Page: http://pages.intnet.mu/jhbpage
> ----------------------------------------------------------------

> -

Re:Detecting when a key has been released


As you are saying TP7 I assume you are talking DOS programming. Under DOS
you can not get key releases only presses DOS  uses BIOS int 16 keyboard
driver that gobles these key releases and the only mask trackable is the
shift/alt/num lock flags at memory location $0040:0017. Under windows it's
different as they pass keypresses and releases up as messages? You might
need to explain more on what you are trying to do to help futher.

Regards Leon

Quote
"Hensley Bass" <hb...@intnet.mu> wrote in message

news:aamm54$u3l$2@news.intnet.mu...
Quote
> Hi,
> I'm using Turbo Pascal 7.0
> I would like to know if there is a way to detect that a key has been
> released.

> --
> ---------------------
> Hensley Bass
> Email Address: hb...@intnet.mu
> Home Page: http://pages.intnet.mu/jhbpage
> ----------------------------------------------------------------

> -

Re:Detecting when a key has been released


JRS:  In article <3cd1516...@news1.prserv.net>, seen in
news:comp.lang.pascal.borland, Leon de Boer <ldeb...@attglobal.net>
wrote at Thu, 2 May 2002 22:30:14 :-

Quote
>"Hensley Bass" <hb...@intnet.mu> wrote in message
>news:aamm54$u3l$2@news.intnet.mu...

>> I'm using Turbo Pascal 7.0
>> I would like to know if there is a way to detect that a key has been
>> released.

>As you are saying TP7 I assume you are talking DOS programming. Under DOS
>you can not get key releases only presses DOS  uses BIOS int 16 keyboard
>driver that gobles these key releases and the only mask trackable is the
>shift/alt/num lock flags at memory location $0040:0017. Under windows it's
>different as they pass keypresses and releases up as messages? You might
>need to explain more on what you are trying to do to help futher.

Quoted order corrected.

Please read TSFAQP #82 and consider whether that refutes your statement,
with particular reference to the line
            keydown[port60h and $7f] := (port60h <= $7f);

Those who ask here should read the FAQ first.
Those who answer here should understand the FAQ first.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Re:Detecting when a key has been released


And before answering with this sort of {*word*99} you should consider what he is
asking
and what has changed since when the FAQ was written.

1.) The solution you give is based on accessing the keyboard controller (the
number
of which escapes me at this moment and they don't make anymore). Most PC's
have integrated chipsets and these ports may not be valid. Next if they are
running
under windows NT, windows 2000 or Windows XP but using  TP7 kiss your
arse goodbye because you just tried to access hardware which you have no
priviliges to do so! This sort of {*word*99} was quite common back in the dim dark
ages
of DOS but I wouldn't try it these days.

2.) Even if the port access works you are going to have to sit on a hard
loop on
the controller if you let DOS run to much and at some point it is going to
access
the controller itself and you keys will vanish. Given we are writing in TP7
how do
we know what DOS functions our code will use? On version of DOS prior to 6
they didn't have partial threading and this sort of stuff probably worked.

Regards Leon

"Dr John Stockton" <s...@merlyn.demon.co.uk> wrote in message
news:BQR8ImE$4Y08EwpQ@merlyn.demon.co.uk...

Quote
> JRS:  In article <3cd1516...@news1.prserv.net>, seen in
> news:comp.lang.pascal.borland, Leon de Boer <ldeb...@attglobal.net>
> wrote at Thu, 2 May 2002 22:30:14 :-
> >"Hensley Bass" <hb...@intnet.mu> wrote in message
> >news:aamm54$u3l$2@news.intnet.mu...

> >> I'm using Turbo Pascal 7.0
> >> I would like to know if there is a way to detect that a key has been
> >> released.

> >As you are saying TP7 I assume you are talking DOS programming. Under DOS
> >you can not get key releases only presses DOS  uses BIOS int 16 keyboard
> >driver that gobles these key releases and the only mask trackable is the
> >shift/alt/num lock flags at memory location $0040:0017. Under windows
it's
> >different as they pass keypresses and releases up as messages? You might
> >need to explain more on what you are trying to do to help futher.

> Quoted order corrected.

> Please read TSFAQP #82 and consider whether that refutes your statement,
> with particular reference to the line
>             keydown[port60h and $7f] := (port60h <= $7f);

> Those who ask here should read the FAQ first.
> Those who answer here should understand the FAQ first.

> --
> ? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00
MIME. ?
>   <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics &
links;
>   <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b.
mFAQ;
>   <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal

FAQ.

Re:Detecting when a key has been released


And YOUR solution is.....l?

Al

Leon de Boer <ldeb...@attglobal.net> wrote in message news:3cd2c5d1_3@news1.prserv.net...

Quote
> And before answering with this sort of {*word*99} you should consider what he is
> asking
> and what has changed since when the FAQ was written.

> 1.) The solution you give is based on accessing the keyboard controller (the
> number
> of which escapes me at this moment and they don't make anymore). Most PC's
> have integrated chipsets and these ports may not be valid. Next if they are
> running
> under windows NT, windows 2000 or Windows XP but using  TP7 kiss your
> arse goodbye because you just tried to access hardware which you have no
> priviliges to do so! This sort of {*word*99} was quite common back in the dim dark
> ages
> of DOS but I wouldn't try it these days.

> 2.) Even if the port access works you are going to have to sit on a hard
> loop on
> the controller if you let DOS run to much and at some point it is going to
> access
> the controller itself and you keys will vanish. Given we are writing in TP7
> how do
> we know what DOS functions our code will use? On version of DOS prior to 6
> they didn't have partial threading and this sort of stuff probably worked.

> Regards Leon

> "Dr John Stockton" <s...@merlyn.demon.co.uk> wrote in message
> news:BQR8ImE$4Y08EwpQ@merlyn.demon.co.uk...
> > JRS:  In article <3cd1516...@news1.prserv.net>, seen in
> > news:comp.lang.pascal.borland, Leon de Boer <ldeb...@attglobal.net>
> > wrote at Thu, 2 May 2002 22:30:14 :-
> > >"Hensley Bass" <hb...@intnet.mu> wrote in message
> > >news:aamm54$u3l$2@news.intnet.mu...

> > >> I'm using Turbo Pascal 7.0
> > >> I would like to know if there is a way to detect that a key has been
> > >> released.

> > >As you are saying TP7 I assume you are talking DOS programming. Under DOS
> > >you can not get key releases only presses DOS  uses BIOS int 16 keyboard
> > >driver that gobles these key releases and the only mask trackable is the
> > >shift/alt/num lock flags at memory location $0040:0017. Under windows
> it's
> > >different as they pass keypresses and releases up as messages? You might
> > >need to explain more on what you are trying to do to help futher.

> > Quoted order corrected.

> > Please read TSFAQP #82 and consider whether that refutes your statement,
> > with particular reference to the line
> >             keydown[port60h and $7f] := (port60h <= $7f);

> > Those who ask here should read the FAQ first.
> > Those who answer here should understand the FAQ first.

> > --
> > ? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00
> MIME. ?
> >   <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics &
> links;
> >   <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b.
> mFAQ;
> >   <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal
> FAQ.

Re:Detecting when a key has been released


JRS:  In article <3cd2c5d...@news1.prserv.net>, seen in
news:comp.lang.pascal.borland, Leon de Boer <ldeb...@attglobal.net>
posted at Sat, 4 May 2002 01:04:02 :-

An ill-mannered and naive response.  Responses should be placed after
trimmed quotes - read the mFAQ sec 1.2, as you have not already done so
sufficiently.

Quote
>And before answering with this sort of {*word*99} you should consider what he is
>asking
>and what has changed since when the FAQ was written.

>1.) The solution you give is based on accessing the keyboard controller (the
>number
>of which escapes me at this moment and they don't make anymore). Most PC's
>have integrated chipsets and these ports may not be valid. Next if they are
>running
>under windows NT, windows 2000 or Windows XP but using  TP7 kiss your
>arse goodbye because you just tried to access hardware which you have no
>priviliges to do so! This sort of {*word*99} was quite common back in the dim dark
>ages
>of DOS but I wouldn't try it these days.

He specified TP7; he may well be running it on a PC of similar age.  I
still use all my PCs, the oldest now being 14 years old.  ISTM that the
advent of integrated chip sets will not have altered its hardware.

Note that YOUR OWN ANSWER referred SPECIFICALLY to operating under DOS.

However, the reference to NT/2000/XP could be of value; the OP did not
specify an OS.

Quote
>2.) Even if the port access works you are going to have to sit on a hard
>loop on
>the controller if you let DOS run to much and at some point it is going to
>access
>the controller itself and you keys will vanish. Given we are writing in TP7
>how do
>we know what DOS functions our code will use? On version of DOS prior to 6
>they didn't have partial threading and this sort of stuff probably worked.

Perhaps you are not familiar with chaining in to interrupts?  Let TSFAQP
#82 introduce you.

ISTM that what you are saying could only be true, in straight DOS, if
the FAQ were wrong.  That seems unlikely; I cannot believe that the code
there has never been tested. ... ...

Moreover, the code cut'n'pasted directly from TSFAQP#82 seems to work as
intended in a Win98 DOS box, and does not interfere with this Mail
application; I see no difference in a ten-year-old DOS 6.20 machine.

With the code in TSFAQP, one CAN detect when a key has been released.

Quote
>Regards Leon

>"Dr John Stockton" <s...@merlyn.demon.co.uk> wrote in message
>> Those who ask here should read the FAQ first.
>> Those who answer here should understand the FAQ first.

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME. ?
  <URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
  <URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> Pedt Scragg: c.l.p.b. mFAQ;
  <URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.

Re:Detecting when a key has been released


Quote
In article <1020457741.730508@savina>, Al Hephy wrote:
> And YOUR solution is.....l?

Don't try to cover all these systems with one (dos) file.

Use a Windows compiler for the NT systems, and separate your application
into a platform dependant and independant part.

For an example for e.g. mouse and keyboard, see the handlers for the free
compilers (e.g. Free Pascal, but e.g. GPC also have such universal units),
and try to backport them to BP.

Re:Detecting when a key has been released


Quote
> He specified TP7; he may well be running it on a PC of similar age.  I
> still use all my PCs, the oldest now being 14 years old.  ISTM that the
> advent of integrated chip sets will not have altered its hardware.

> Note that YOUR OWN ANSWER referred SPECIFICALLY to operating under DOS.

So now we are giving FAQ answers that MIGHT work on some old mueseum piece
or if we are extremely lucky on modern hardware in certain situations.

I stand by what I said don't do it!!!
Explain what you are trying to do and we will see what we can suggest!!

Quote
> However, the reference to NT/2000/XP could be of value; the OP did not
> specify an OS.

Exactly I said lets assume DOS.

Quote
> >2.) Even if the port access works you are going to have to sit on a hard
> >loop on
> >the controller if you let DOS run to much and at some point it is going
to
> >access
> >the controller itself and you keys will vanish. Given we are writing in
TP7
> >how do
> >we know what DOS functions our code will use? On version of DOS prior to
6
> >they didn't have partial threading and this sort of stuff probably
worked.

> Perhaps you are not familiar with chaining in to interrupts?  Let TSFAQP
> #82 introduce you.

Agreed but NOW we are chaining interrupts in TP7 (i know it can be done)
but really this is a job for assembler where you know what is happening to
the registers are we suggesting this as an FAQ.

Quote
> ISTM that what you are saying could only be true, in straight DOS, if
> the FAQ were wrong.  That seems unlikely; I cannot believe that the code
> there has never been tested. ... ...

> Moreover, the code cut'n'pasted directly from TSFAQP#82 seems to work as
> intended in a Win98 DOS box, and does not interfere with this Mail
> application; I see no difference in a ten-year-old DOS 6.20 machine.

> With the code in TSFAQP, one CAN detect when a key has been released.

Reminds me of what the captain of the Titanic must have said?
But who am I to argue you are a Dr and me just a deckhand.

Regards Leon

Re:Detecting when a key has been released


Quote
"Al Hephy" <AHep...@freewweb.invalid> wrote in message

news:1020457741.730508@savina...
And YOUR solution is.....l?

Al

1.) Find out what is trying to be done and why
     - Is there a better way
     - Is there another way
2.) If we still need to do it and we are on DOS boxes
     - You can still actually get limited access windows system use it to
get key up events
     - The above approach will require tests to find operating systems
3.) Are we definitely confined to DOS can we not have a windows console app
if we are to run on  modern machines

Probably thousands of other choices depends on whats being attempted.

Regards Leon

Re:Detecting when a key has been released


Hi,
I use Turbo Pascal 7.0 for DOS. Stefan G?hler's answer, in the previous
post, provided the solution for almost all of my initial question.
I'm not conversant with the bios interrupts. Is there any tutorial available
online?

--
---------------------
Hensley Bass
Email Address: hb...@intnet.mu
Home Page: http://pages.intnet.mu/jhbpage
----------------------------------------------------------------

-
Leon de Boer <ldeb...@attglobal.net> wrote in message
news:3cd15160_3@news1.prserv.net...

Quote
> As you are saying TP7 I assume you are talking DOS programming. Under DOS
> you can not get key releases only presses DOS  uses BIOS int 16 keyboard
> driver that gobles these key releases and the only mask trackable is the
> shift/alt/num lock flags at memory location $0040:0017. Under windows it's
> different as they pass keypresses and releases up as messages? You might
> need to explain more on what you are trying to do to help futher.

> Regards Leon

> "Hensley Bass" <hb...@intnet.mu> wrote in message
> news:aamm54$u3l$2@news.intnet.mu...
> > Hi,
> > I'm using Turbo Pascal 7.0
> > I would like to know if there is a way to detect that a key has been
> > released.

> > --
> > ---------------------
> > Hensley Bass
> > Email Address: hb...@intnet.mu
> > Home Page: http://pages.intnet.mu/jhbpage
> > ----------------------------------------------------------------

> > -

Re:Detecting when a key has been released


Ralph Brown put out an interrupt list that was fairly comprehensive if you
do a search for it on your favourite search engine it will answer most
stuff.

Regards Leon

Quote
"Hensley Bass" <hb...@intnet.mu> wrote in message

news:ab3t1i$90o$1@news.intnet.mu...
Quote
> Hi,
> I use Turbo Pascal 7.0 for DOS. Stefan G?hler's answer, in the previous
> post, provided the solution for almost all of my initial question.
> I'm not conversant with the bios interrupts. Is there any tutorial
available
> online?

> --
> ---------------------
> Hensley Bass
> Email Address: hb...@intnet.mu
> Home Page: http://pages.intnet.mu/jhbpage
> ----------------------------------------------------------------

> -
> Leon de Boer <ldeb...@attglobal.net> wrote in message
> news:3cd15160_3@news1.prserv.net...
> > As you are saying TP7 I assume you are talking DOS programming. Under
DOS
> > you can not get key releases only presses DOS  uses BIOS int 16 keyboard
> > driver that gobles these key releases and the only mask trackable is the
> > shift/alt/num lock flags at memory location $0040:0017. Under windows
it's
> > different as they pass keypresses and releases up as messages? You might
> > need to explain more on what you are trying to do to help futher.

> > Regards Leon

> > "Hensley Bass" <hb...@intnet.mu> wrote in message
> > news:aamm54$u3l$2@news.intnet.mu...
> > > Hi,
> > > I'm using Turbo Pascal 7.0
> > > I would like to know if there is a way to detect that a key has been
> > > released.

> > > --
> > > ---------------------
> > > Hensley Bass
> > > Email Address: hb...@intnet.mu
> > > Home Page: http://pages.intnet.mu/jhbpage
> > > ----------------------------------------------------------------

> > > -

Re:Detecting when a key has been released


JRS:  In article <3cd670e...@news1.prserv.net>, seen in
news:comp.lang.pascal.borland, Leon de Boer <ldeb...@attglobal.net>
posted at Mon, 6 May 2002 19:50:44 :-

Quote
>Lines: 59

>Ralph Brown put out an interrupt list that was fairly comprehensive if you
>do a search for it on your favourite search engine it will answer most
>stuff.

>Regards Leon

>"Hensley Bass" <hb...@intnet.mu> wrote in message
>news:ab3t1i$90o$1@news.intnet.mu...
>> Hi,
>> I use Turbo Pascal 7.0 for DOS. Stefan G?hler's answer, in the previous
>> post, provided the solution for almost all of my initial question.

>> ...

That is true; I know that there is at least one site which specifically
refers to the name Ralph Brown in order to be able to redirect those who
are unable to spell Ralf Brown's name correctly.

However, when posting answers to a newsgroup it is wise to be thoroughly
familiar with the FAQ of that group.  If you had taken that precaution,
you would have known that links to RBIL are maintained there; you could
have indicated a direct means of access.

But there is no need for you to inflict all that upside-down over-
quoting on the rest of us.  You have already had your attention drawn to
the mFAQ of this newsgroup, which gives adequate guidance; you should
also read what TS and others have written on the subject of the proper,
efficient use of this communication medium (references below).

You need not claim that the arguments therein are outdated nowadays when
fast cheap links are available to some; they are not available to all,
and not always available to others.  Moreover, it is clear that the
human brain has not correspondingly increased its capability; therefore
the need for effective composition remains..

--
? John Stockton, Surrey, UK.  j...@merlyn.demon.co.uk   Turnpike v4.00   MIME ?
 Web <URL:http://www.uwasa.fi/~ts/http/tsfaq.html> -> Timo Salmi: Usenet Q&A.
 Web <URL:http://www.merlyn.demon.co.uk/news-use.htm> :  about usage of News.
No Encoding. Quotes before replies. Snip well. Write clearly. Don't Mail News.

Re:Detecting when a key has been released


Quote
> That is true; I know that there is at least one site which specifically
> refers to the name Ralph Brown in order to be able to redirect those who
> are unable to spell Ralf Brown's name correctly.

Guess he should get his mother to spell right ;}

Quote
> But there is no need for you to inflict all that upside-down over-
> quoting on the rest of us.  You have already had your attention drawn to
> the mFAQ of this newsgroup, which gives adequate guidance; you should
> also read what TS and others have written on the subject of the proper,
> efficient use of this communication medium (references below).

Now you will have to argue that one with Microsoft it does all the what
you call upside down quoting as part of our internal e-mail server on
Windows 2000 server. It is actually the default settings whatever that is,
who gives a toss that's why I pay my IT man very little ;}

Hey maybe thats it! His way of getting back at me, bastard he's sacked!!!!!

Quote
> You need not claim that the arguments therein are outdated nowadays when
> fast cheap links are available to some; they are not available to all,
> and not always available to others.  Moreover, it is clear that the
> human brain has not correspondingly increased its capability; therefore
> the need for effective composition remains..

I think I am being insulted but given that all I do is programming for a
living
my brain died long ago...now where is that coke ;}

Regards Leon

Other Threads