Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Detecting multiple keypresses

Reply
Thread Tools

Detecting multiple keypresses

 
 
kstahl
Guest
Posts: n/a
 
      05-12-2004
Howdy,

I would like to get down to the nitty-gritty of the keyboard's operation.
Specifically, I would like to poll only a few keys on the keyboard, and I
would like to know when more than one key is pressed. In other words, I
would like to know how to access the keyboard's scan lines, so that if, for
example, the user is holding two of the arrow keys pressed simultaneously, I
will get a continuously changing response of Left-Right-Left-Right-and so
on. So far, all that comes to mind is scanf(), but this is clearly
inadequate.

Thanks for your help,
-Karl


 
Reply With Quote
 
 
 
 
Joona I Palaste
Guest
Posts: n/a
 
      05-12-2004
kstahl <(E-Mail Removed)> scribbled the following:
> Howdy,


> I would like to get down to the nitty-gritty of the keyboard's
> operation.


Can't be done in ISO standard C. Strictly speaking, you can't read the
keyboard at all in ISO standard C, merely the standard input stream.
Fortunately, most of the time there is a console handler reading the
keyboard and feeding the characters to the standard input stream. How it
does that is off-topic for comp.lang.c.

--
/-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"Remember: There are only three kinds of people - those who can count and those
who can't."
- Vampyra
 
Reply With Quote
 
 
 
 
kstahl
Guest
Posts: n/a
 
      05-12-2004
Thanks for your prompt response. I'm not familiar with "console handlers" -
can you recommend a newgroup/website where I might learn more about such
topics?


"Joona I Palaste" <(E-Mail Removed)> wrote in message
news:c7tsvt$hd9$(E-Mail Removed)...
> kstahl <(E-Mail Removed)> scribbled the following:
> > Howdy,

>
> > I would like to get down to the nitty-gritty of the keyboard's
> > operation.

>
> Can't be done in ISO standard C. Strictly speaking, you can't read the
> keyboard at all in ISO standard C, merely the standard input stream.
> Fortunately, most of the time there is a console handler reading the
> keyboard and feeding the characters to the standard input stream. How it
> does that is off-topic for comp.lang.c.
>
> --
> /-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
> \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
> "Remember: There are only three kinds of people - those who can count and

those
> who can't."
> - Vampyra



 
Reply With Quote
 
Joona I Palaste
Guest
Posts: n/a
 
      05-12-2004
kstahl <(E-Mail Removed)> scribbled the following:
> Thanks for your prompt response. I'm not familiar with "console handlers" -
> can you recommend a newgroup/website where I might learn more about such
> topics?


It depends on what operating system you are using. Here are a few
suggestions.
For MS Windows: comp.os.ms-windows.programmer
For Unix/Linux: comp.unix.programmer

--
/-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"To doo bee doo bee doo."
- Frank Sinatra
 
Reply With Quote
 
Neil Kurzman
Guest
Posts: n/a
 
      05-13-2004
oona I Palaste wrote:

> kstahl <(E-Mail Removed)> scribbled the following:
> > Howdy,

>
> > I would like to get down to the nitty-gritty of the keyboard's
> > operation.

>
> Can't be done in ISO standard C. Strictly speaking, you can't read the
> keyboard at all in ISO standard C, merely the standard input stream.
> Fortunately, most of the time there is a console handler reading the
> keyboard and feeding the characters to the standard input stream. How it
> does that is off-topic for comp.lang.c.
>
> --
> /-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
> \-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
> "Remember: There are only three kinds of people - those who can count and those
> who can't."
> - Vampyra


With PC hardware it is not possible. getch() will give you a Key and scan code.
There is no held down status.



 
Reply With Quote
 
Thomas Matthews
Guest
Posts: n/a
 
      05-13-2004
Neil Kurzman wrote:
> oona I Palaste wrote:
>
>
>>kstahl <(E-Mail Removed)> scribbled the following:
>>
>>>Howdy,

>>
>>>I would like to get down to the nitty-gritty of the keyboard's
>>>operation.

>>
>>Can't be done in ISO standard C. Strictly speaking, you can't read the
>>keyboard at all in ISO standard C, merely the standard input stream.
>>Fortunately, most of the time there is a console handler reading the
>>keyboard and feeding the characters to the standard input stream. How it
>>does that is off-topic for comp.lang.c.
>>
>>--
>>/-- Joona Palaste ((E-Mail Removed)) ------------- Finland --------\
>>\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
>>"Remember: There are only three kinds of people - those who can count and those
>>who can't."
>> - Vampyra

>
>
> With PC hardware it is not possible. getch() will give you a Key and scan code.
> There is no held down status.
>
>
>


Then how does Windows obtain the data for its key press messages?
Last time I looked, the Windows operating system could differentiate
between when a key was pressed and released.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book

 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      05-13-2004
In <LXLoc.2401$(E-Mail Removed)> Thomas Matthews <(E-Mail Removed)> writes:

>Then how does Windows obtain the data for its key press messages?
>Last time I looked, the Windows operating system could differentiate
>between when a key was pressed and released.


IIRC (back in my MSDOS days I used to play with the keyboard interface of
the PC, but it's been 15 years ago...) the keyboard is "seen" as an 8-bit
port at some I/O address that "remembers" the last event received from
the keyboard. 7 bits are used for the scan code and 1 bit to indicate
whether the key was pressed or released.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
Alan Balmer
Guest
Posts: n/a
 
      05-13-2004
On Thu, 13 May 2004 14:51:23 GMT, Thomas Matthews
<(E-Mail Removed)> wrote:

>
>Then how does Windows obtain the data for its key press messages?
>Last time I looked, the Windows operating system could differentiate
>between when a key was pressed and released.
>

There are separate scan codes for key down and key up. However, it's
*still* not topical here - take the discussion to some place like
comp.os.ms-windows.programmer, where the answers will be more
plentiful and more accurate.

--
Al Balmer
Balmer Consulting
(E-Mail Removed)
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
keypresses and signal handling Rich C Programming 29 09-27-2010 10:31 AM
Respond to keypresses on top of a paragraph mflll@wiu.edu Javascript 1 04-14-2007 04:48 PM
intercepting keypresses, mouse movements, joystick movements. bryan rasmussen Python 2 10-09-2006 07:11 PM
How do I scan for keypresses in console ruby? Myrddin Emrys Ruby 1 07-24-2006 06:04 PM
Re: JTable in Applet doesn't receive keypresses under Win2000 (XP is Ok) Dag Sunde Java 0 12-30-2004 04:16 PM



Advertisments