Re: Key-press detection



CBFalconer said:

David Sweeney wrote:

I am using C++ (with the Visual C++ compiler) on Windows XP, and
I am hoping to develop a simple computer game. I would like to
know if there is a way to detect which key the user is pressing,
eg, if the user is pressing 'a', can that be transferred into a
character? Can you write:

char c = GetKeyPress();

or something similar?

Not without using something non-standard and system-specific. Most
systems that handle keyboards have means of handling this, but it
can't be standard, because the keyboard may not exist.

If there's no keyboard, it's likely to be quite a short game.

Or perhaps a long one, since the user won't be able to quit! :-)

Note that he did not ask for a standard solution, but for a solution
that works on his platform. (Strictly speaking, he's asking in the
wrong group - he should be over in c.o.m-w.p.w32 - and no doubt this is
the point you're really trying to make.)

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
.



Relevant Pages

  • Re: Key-press detection
    ... David Sweeney wrote: ... I am hoping to develop a simple computer game. ... know if there is a way to detect which key the user is pressing, ... systems that handle keyboards have means of handling this, ...
    (comp.programming)
  • Problem using wireless mouse and keyboard simultaneously in games
    ... to a Microsoft Wireless Optical Mouse and Microsoft Wireless Keyboard. ... Every computer game that I play such as Far Cry, Medal of Honour, Unreal ... Tournament 2004 etc requires the user to use the mouse and keyboard at the ... that the hardware can't seem to deal with multiple devices at the same time ...
    (microsoft.public.windowsxp.hardware)
  • RE: MS wireless keyboard gaming issue...
    ... The slowing down the repeat rate did help, but this keyboard ... > I have the MS Wireless Comfort Keyboard 1.0A (this is what is giving me the ... > ATI X850 XT Plat ... when I'm play a PC computer game and ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: Key-press detection
    ... hoping to develop a simple computer game. ... a way to detect which key the user is pressing, eg, if the user is pressing ... callback functions and what language you're using. ... What langauge ARE you using? ...
    (comp.programming)
  • Key-press detection
    ... to develop a simple computer game. ... detect which key the user is pressing, eg, if the user is pressing 'a', can ... char c = GetKeyPress; ... Mny thanks for help on this! ...
    (comp.programming)