I would like to know the state of the keyboard.
more precisely I would like to know if the 'SPACE' key is pressed or not.
how od I do that?

--
Regards,
Lloyd Dupont

NovaMind development team
NovaMind Software
Mind Mapping Software
<www.nova-mind.com>

Re: get key state by Lloyd

Lloyd
Tue Sep 20 20:56:21 CDT 2005

This is a multi-part message in MIME format.

------=_NextPart_000_0225_01C5BEA3.7BFD1F20
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Found it:
[SuppressUnmanagedCodeSecurity]
public class KeyState
{
[DllImport("user32.dll")]
static extern short GetKeyState(int nVirtKey);
public static bool GetKeyPressed(Keys key)
{
short state =3D GetKeyState((int) key);
return state !=3D 0;
}

Just a bit disappointed the Keyboard class doesn't return it...


"Lloyd Dupont" <net.galador@ld> wrote in message =
news:eabD7ykvFHA.2728@TK2MSFTNGP14.phx.gbl...
>I would like to know the state of the keyboard.
> more precisely I would like to know if the 'SPACE' key is pressed or =
not.
> how od I do that?
>=20
> --=20
> Regards,
> Lloyd Dupont
>=20
> NovaMind development team
> NovaMind Software
> Mind Mapping Software
> <www.nova-mind.com>=20
>=20
>
------=_NextPart_000_0225_01C5BEA3.7BFD1F20
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2900.2722" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2>Found it:<BR></FONT><FONT =
size=3D2>[</FONT><FONT=20
color=3D#008080 size=3D2>SuppressUnmanagedCodeSecurity</FONT><FONT=20
size=3D2>]<BR></FONT><FONT color=3D#0000ff size=3D2>public</FONT><FONT =
size=3D2>=20
</FONT><FONT color=3D#0000ff size=3D2>class</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#008080 size=3D2>KeyState<BR></FONT><FONT =
size=3D2>{<BR>&nbsp;&nbsp;&nbsp;=20
[</FONT><FONT color=3D#008080 size=3D2>DllImport</FONT><FONT =
size=3D2>(</FONT><FONT=20
color=3D#800000 size=3D2>"user32.dll"</FONT><FONT =
size=3D2>)]<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; static</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#0000ff size=3D2>extern</FONT><FONT size=3D2> </FONT><FONT =
color=3D#0000ff=20
size=3D2>short</FONT><FONT size=3D2> GetKeyState(</FONT><FONT =
color=3D#0000ff=20
size=3D2>int</FONT><FONT size=3D2> nVirtKey);<BR></FONT><FONT =
color=3D#0000ff=20
size=3D2>&nbsp;&nbsp;&nbsp; public</FONT><FONT size=3D2> </FONT><FONT =
color=3D#0000ff=20
size=3D2>static</FONT><FONT size=3D2> </FONT><FONT color=3D#0000ff=20
size=3D2>bool</FONT><FONT size=3D2> GetKeyPressed(</FONT><FONT =
color=3D#008080=20
size=3D2>Keys</FONT><FONT size=3D2> key)<BR>&nbsp;&nbsp;&nbsp; =
{<BR></FONT><FONT=20
color=3D#0000ff size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
short</FONT><FONT=20
size=3D2> state =3D GetKeyState((</FONT><FONT color=3D#0000ff =
size=3D2>int</FONT><FONT=20
size=3D2>) key);<BR></FONT><FONT color=3D#0000ff =
size=3D2>&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; return</FONT><FONT size=3D2> state !=3D =
0;<BR>&nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2><FONT face=3DArial>Just a bit disappointed the =
Keyboard class=20
doesn't return it...</FONT></DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=3DArial size=3D2>"Lloyd Dupont" &lt;</FONT><A=20
href=3D"mailto:net.galador@ld"><FONT face=3DArial=20
size=3D2>net.galador@ld</FONT></A><FONT face=3DArial size=3D2>&gt; wrote =
in message=20
</FONT><A href=3D"news:eabD7ykvFHA.2728@TK2MSFTNGP14.phx.gbl"><FONT =
face=3DArial=20
size=3D2>news:eabD7ykvFHA.2728@TK2MSFTNGP14.phx.gbl</FONT></A><FONT =
face=3DArial=20
size=3D2>...</FONT></DIV><FONT face=3DArial size=3D2>&gt;I would like to =
know the=20
state of the keyboard.<BR>&gt; more precisely I would like to know if =
the=20
'SPACE' key is pressed or not.<BR>&gt; how od I do that?<BR>&gt; =
<BR>&gt; --=20
<BR>&gt; Regards,<BR>&gt; Lloyd Dupont<BR>&gt; <BR>&gt; NovaMind =
development=20
team<BR>&gt; NovaMind Software<BR>&gt; Mind Mapping Software<BR>&gt;=20
&lt;</FONT><A href=3D"http://www.nova-mind.com"><FONT face=3DArial=20
size=3D2>www.nova-mind.com</FONT></A><FONT face=3DArial size=3D2>&gt; =
<BR>&gt;=20
<BR>&gt;</FONT></BODY></HTML>

------=_NextPart_000_0225_01C5BEA3.7BFD1F20--