Reading function/cursor keys 
Author Message
 Reading function/cursor keys



Quote:



> >This is my point of view - so if I'm wrong, please correct me.
> >Apparently, every key or keycombination fills the keyboardbuffer
with
> >two bytes (a word?), probably to fill up the 16 bits. When pressing
a
> >special key or keycombination the second byte will get the
(hex)value
> >00. This is what I can deduct from reading all those 'special key'
> >codes.
> >If the compiler reads the buffer he will first read the second
byte.
> >when a 00 is met, he 'knows' another byte is{*filter*} around and
will
> >not clear the buffer until asked to do so,
> >however when the second byte does not equal 00, a 'normal' key is
> >pressed and the buffer will be cleared automatically (?).
> >As I stated before, this is my humble opinion, so if anyone knows
more
> >about this:
> >I'm always willing to learn.
> >Hope this helped a Bit,

> I do not know what you are talking about. The internal
representation
> of the keyboard buffer is not relevant. What Readkey does is it uses
Int
> 16h, ah=0 to read a scancode, ASCII code pair. It returns the ASCII
> code. If the ASCII code is zero, then it stores the scan code into
an
> internal buffer. The next time it is called it checks the buffer if
> there is scancode available and if there is it is returned instead.

> Here are Pascal versions of readkey and keypressed:

> const scancode:char=#0;

> function readkey:char;
> var rg:registers;
> begin
>   if scancode>#0 then begin
>       readkey:=scancode;
>       scancode:=#0;
>       exit;
>   End;
>   rg.ah:=0;
>   intr($16,rg);
>   readkey:=chr(rg.al);
>   if rg.al=0 then scancode:=chr(rg.ah);
> End;

> function keypressed:boolean;
> var rg:registers;
> begin
>   if scancode>#0 then keypressed:=true
>     else begin
>            rg.ah:=1;
>            intr($16,rg);
>            keypressed:=rg.flags and fzero=0;
>          End;
> End;

> Note that the buffer where the scancode is store is internal to CRT,
it
> has nothing to do with the BIOS keyboard buffer.

> Osmo

Osmo,
thanks for clarifying things up for me,
I saved your answer to my harddisk (as I do with many others), so I
can learn from it.
As I said in my posting, my "guess" was a deduction from the things I
knew and saw.
Still, I'm stuck with the same question as Frederic, what is the
meaning of this high byte for a "normal" key, or isn't there a meaning
at all?
Marcel
--
Please remove the *.NoSpam* entry from my eMail address when replying.
It's meant to keep Spam and Advertising out, not friends.
Please test my new web pages
http://www.*-*-*.com/
still under heavy construction


Wed, 18 Jun 1902 08:00:00 GMT  
 Reading function/cursor keys
Why would I be joking? I really can't stand you people who think that
just because you know how to program, you think you're 'IT'.
Quote:

> On Sun 11 Jun 2000 01:58:45p,  In article


> >Can someone please tell me how I can read the function and cursor keys?

> >Any help appreciated

> You're joking, right?  You ARE joking, right?



Wed, 18 Jun 1902 08:00:00 GMT  
 Reading function/cursor keys

Quote:

>Why would I be joking? I really can't stand you people who think that
>just because you know how to program, you think you're 'IT'.

James,

It has nothing to do with "knowing how to program" or being "IT".

The issue at hand is netiquette.

At the time you posted your question, there was already an active
thread titled "read cursor keys" discussing the very question you
asked.

You obviously didn't bother to look at the ongoing discussions before posting
your question.  That is considered rude.

Your righteous indignation is misplaced.

Fifty dollars please.



Wed, 18 Jun 1902 08:00:00 GMT  
 Reading function/cursor keys
i didn't see that thread cos my newsgroup reader only showed me stuff
from the day i posted my thread. sorry if i appeared to be rude, but i
wasn't to know
Quote:


> >Why would I be joking? I really can't stand you people who think that
> >just because you know how to program, you think you're 'IT'.

> James,

> It has nothing to do with "knowing how to program" or being "IT".

> The issue at hand is netiquette.

> At the time you posted your question, there was already an active
> thread titled "read cursor keys" discussing the very question you
> asked.

> You obviously didn't bother to look at the ongoing discussions before posting
> your question.  That is considered rude.

> Your righteous indignation is misplaced.

> Fifty dollars please.



Wed, 18 Jun 1902 08:00:00 GMT  
 Reading function/cursor keys

Quote:
> Osmo,
> thanks for clarifying things up for me,
> I saved your answer to my harddisk (as I do with many others), so I
> can learn from it.
> As I said in my posting, my "guess" was a deduction from the things I
> knew and saw.
> Still, I'm stuck with the same question as Frederic, what is the
> meaning of this high byte for a "normal" key, or isn't there a meaning
> at all?

As Osmo said in his post, that byte is the scancode for the key pressed,
which is essentially keyboard layout information in the case of a normal
key. So it can safely be ignored unless the low byte is 0, or if you need to
test for numeric keypad keys or something similarly arcane.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Source Code For Using Function Keys or Cursor Keys - Help :)

2. Source Code For Using Function Keys or Cursor Keys - H

3. read cursor keys

4. read cursor key

5. Reading the Function keys

6. how to read a function key press?

7. Using the Function Keys and The Escape Key

8. How to put cursor-keys in keyboard buffer??

9. !!! Help, Cursor Keys

10. How control Cursor-Keys with TPW 1.5 in a WinCRT-Window

11. How control Cursor-Keys with TPW 1.5 in a WinCRT-Window

12. Cursor Keys

 

 
Powered by phpBB® Forum Software