<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Escape not being read straight off?</title>
		<link>http://www.allegro.cc/forums/view/588245</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Tue, 31 Oct 2006 07:48:02 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>In my program, I use the left control key as my fire button, and the escape key to exit the game. </p><p>If I press the left control key, and then press escape, nothing happens. But if I press left control, then another key (in this case the space bar), and then escape, the game exits.</p><p>I&#39;ve put a poll_keyboard() before the test for the escape key, in case that was needed, but no luck.</p><p>Is there any reason for the keyboard to behave in this manner? Why isn&#39;t an escape key press registered after I&#39;ve pressed the left control key?</p><p>Jeroen
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Sat, 28 Oct 2006 00:00:43 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you are using readkey(), it might change the scancodes or something. Really though, I can&#39;t help too much right now. It might make it easier if you showed us some of your code, though.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kikaru)</author>
		<pubDate>Sat, 28 Oct 2006 00:29:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Code?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Jonatan Hedborg)</author>
		<pubDate>Sat, 28 Oct 2006 00:31:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Do you have something like sticky keys enabled?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 28 Oct 2006 01:05:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>the code that checks for the escape key is:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">while</span> <span class="k2">(</span><span class="k2">(</span><span class="k3">!</span><a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_ESC<span class="k2">]</span><span class="k2">)</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> <span class="k2">(</span>invaders.invadersLeft<span class="k2">(</span><span class="k2">)</span> <span class="k3">!</span><span class="k3">=</span> <span class="n">0</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">2</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">3</td><td>    <a href="http://www.allegro.cc/manual/clear_to_color" target="_blank"><span class="a">clear_to_color</span></a><span class="k2">(</span>buffer, <span class="n">0</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td>    bullets.moveAll<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">6</td><td>    player.moveAndFire<span class="k2">(</span><span class="k3">&amp;</span>bullets, <span class="k3">&amp;</span>invaders, xPlayer, yPlayer<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td>&#160;</td></tr><tr><td class="number">8</td><td><span class="k2">[</span>cut out other drawing bits<span class="k2">]</span></td></tr><tr><td class="number">9</td><td>&#160;</td></tr><tr><td class="number">10</td><td>    player.draw<span class="k2">(</span>buffer<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">11</td><td>&#160;</td></tr><tr><td class="number">12</td><td>    <a href="http://www.allegro.cc/manual/blit" target="_blank"><span class="a">blit</span></a><span class="k2">(</span>buffer, <a href="http://www.allegro.cc/manual/screen" target="_blank"><span class="a">screen</span></a>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, <span class="n">0</span>, buffer-&gt;w, buffer-&gt;h<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>    <a href="http://www.allegro.cc/manual/poll_keyboard" target="_blank"><span class="a">poll_keyboard</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>  <span class="k2">}</span></td></tr></tbody></table></div></div><p>

Jeroen</p><p>the code that checks the left control key is player.moveAndFire:</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">void</span> cPlayer::moveAndFire<span class="k2">(</span>cBullets <span class="k3">*</span>bulletList, cInvaders <span class="k3">*</span>invaderList, <span class="k1">int</span> <span class="k3">&amp;</span>xPos, <span class="k1">int</span> <span class="k3">&amp;</span>yPos<span class="k2">)</span></td></tr><tr><td class="number">2</td><td><span class="k2">{</span></td></tr><tr><td class="number">3</td><td>  <span class="k1">int</span> xClosest, yClosest<span class="k2">;</span></td></tr><tr><td class="number">4</td><td>  </td></tr><tr><td class="number">5</td><td>  shield.move<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">6</td><td>  x <span class="k3">+</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_RIGHT<span class="k2">]</span> <span class="k3">&amp;</span> x <span class="k3">&lt;</span> <span class="n">620</span><span class="k2">;</span></td></tr><tr><td class="number">7</td><td>  x <span class="k3">-</span><span class="k3">=</span> <a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_LEFT<span class="k2">]</span> <span class="k3">&amp;</span> x <span class="k3">&gt;</span> <span class="n">20</span><span class="k2">;</span></td></tr><tr><td class="number">8</td><td>&#160;</td></tr><tr><td class="number">9</td><td>  <span class="k1">if</span> <span class="k2">(</span><a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_LCONTROL<span class="k2">]</span> <span class="k3">&amp;</span><span class="k3">&amp;</span> fireDelay <span class="k3">&lt;</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_103.html" target="_blank">clock</a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span></td></tr><tr><td class="number">10</td><td>  <span class="k2">{</span></td></tr><tr><td class="number">11</td><td>    fireDelay <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_103.html" target="_blank">clock</a><span class="k2">(</span><span class="k2">)</span> <span class="k3">+</span> <span class="k2">(</span>clock_t<span class="k2">)</span><span class="k2">(</span><span class="n">0</span>.<span class="n">1</span><span class="k3">*</span>CLOCKS_PER_SEC<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>    bulletList-&gt;add<span class="k2">(</span>x, y <span class="k3">-</span> halfHeight, <span class="n">0</span>, <span class="k3">-</span><span class="n">4</span>, bullet_base<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>  <span class="k2">}</span></td></tr><tr><td class="number">14</td><td>  invaderList-&gt;closest<span class="k2">(</span>xClosest, yClosest<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>  bulletList-&gt;setSpecial<span class="k2">(</span>x, y <span class="k3">-</span> halfHeight, xClosest, yClosest, <a href="http://www.allegro.cc/manual/key" target="_blank"><span class="a">key</span></a><span class="k2">[</span>KEY_SPACE<span class="k2">]</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">16</td><td>&#160;</td></tr><tr><td class="number">17</td><td>  xPos <span class="k3">=</span> x<span class="k2">;</span></td></tr><tr><td class="number">18</td><td>  yPos <span class="k3">=</span> y <span class="k3">-</span> halfHeight<span class="k2">;</span></td></tr><tr><td class="number">19</td><td>  <span class="k2">}</span></td></tr></tbody></table></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Sat, 28 Oct 2006 01:31:13 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>How quickly in succession are you pressing your keys (Ctrl then Esc)?  If you&#39;re using Windows, Ctrl+Esc is something that the OS looks at (I think it toggles something IIRC).  If you&#39;re hitting Ctrl, then waiting a few seconds, then hitting ESC, I&#39;m not really sure what that could be...</p><p>Could you try checking for both these keys simultaneously, and if so, give you a message or something that will tell you &quot;A hotkey was pressed...&quot; so you can see whether the OS/keyboard/whatever is actually &quot;remembering&quot; the Ctrl key for you?</p><p>-TT
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeamTerradactyl)</author>
		<pubDate>Sat, 28 Oct 2006 12:47:45 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It happens when I press down the control key once, or just hold it down. But I always release it and wait for a second or so before I try the escape key.</p><p>TeamTerradactyl: I&#39;ll try your suggestions, and, from what you&#39;ve said, I have thought up a couple more tests I can try. I&#39;m not too fussed by it as yet, but it is a curiosity and I was wondering if anyone else had experienced the problem.</p><p>Chances are I&#39;m doing something naff in my code without realising it.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Sat, 28 Oct 2006 15:51:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title">I said:</div><div class="quote"><p>
Do you have something like sticky keys enabled?
</p></div></div><p>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Evert)</author>
		<pubDate>Sat, 28 Oct 2006 15:59:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>No, I turned sticky keys off soon after I first installed windows on my PC.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Sat, 28 Oct 2006 16:08:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I&#39;ve &quot;turned sticky keys off&quot; eight or nine times to no avail.  It&#39;s broken.  I like to use &quot;shift&quot; keys for &quot;run&quot; with the arrow keys and it keeps bringing up that stupid dialog box no matter what. (holding shift key down for 12 seconds or some such)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Arthur Kalliokoski)</author>
		<pubDate>Mon, 30 Oct 2006 03:19:57 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>When I turned mine off the messagebox stopped popping up. </p><p>If a solution cannot be found, I&#39;ll just use another key for firing.</p><p>Jeroen
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (HardTranceFan)</author>
		<pubDate>Mon, 30 Oct 2006 03:39:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>My only problem is having the Google Desktop search pop up anytime I hit Ctrl twice in a row :-)</p><p>IIRC, hit SHIFT five or so times until StickyKeys dialog opens.  When it does, there should be both a checkbox and a button for each of those settings.</p><p>All 3 of my checkboxes are unchecked, but under each button, the top checkmark was checked, so the settings were still enabled.  Uncheck the first checkboxes from each of those 3 buttons, and let us know if that turns it off for you...</p><p>-TT
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (TeamTerradactyl)</author>
		<pubDate>Tue, 31 Oct 2006 07:48:02 +0000</pubDate>
	</item>
</rss>
