<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>getKey Behavior and Mysteries</title>
		<link>http://tibasicdev.wikidot.com/forum/t-13832494/getkey-behavior-and-mysteries</link>
		<description>Posts in the discussion thread &quot;getKey Behavior and Mysteries&quot; - Confusion about the getKey variable and why certain things happen...</description>
				<copyright></copyright>
		<lastBuildDate>Sat, 07 Mar 2026 11:50:35 +0000</lastBuildDate>
		
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-13832494#post-4803204</guid>
				<title>Re: getKey Behavior and Mysteries</title>
				<link>http://tibasicdev.wikidot.com/forum/t-13832494/getkey-behavior-and-mysteries#post-4803204</link>
				<description></description>
				<pubDate>Sat, 24 Oct 2020 17:22:21 +0000</pubDate>
				<wikidot:authorName>CalcNerd</wikidot:authorName>				<wikidot:authorUserId>6321217</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I think that I figured out why the first program does what it does.<br /> The value of getKey is reset every time the loop goes back to the beginning. When you use the getKey command, it sets the value to zero every time when a key is pressed. I put in a pause at the beginning of my test program to see what the value of getkey would be&#8230;</p> <p>&quot;The solution is to run a &quot;dummy&quot; getKey just before the loop begins — its value won't be used for anything, and it will reset the value of getKey to 0. This can also be used to clear keypresses meant for loading programs from inside a shell.&quot;</p> <p>This quote is from the getKey page. I believe what it is referring to is that you put a line of getKey and it resets the value of it to zero.</p> <p>As for your second program, I will have to do some more testing and reading to try to help you</p> <p>Hope this helps!</p> <div class="code"> <pre><code>: Pause getKey : ClrHome : While 1 : getKey-&gt;K : Disp K : End</code></pre></div> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-13832494#post-4802740</guid>
				<title>Re: getKey Behavior and Mysteries</title>
				<link>http://tibasicdev.wikidot.com/forum/t-13832494/getkey-behavior-and-mysteries#post-4802740</link>
				<description></description>
				<pubDate>Sat, 24 Oct 2020 03:45:07 +0000</pubDate>
				<wikidot:authorName>Pixel Physics</wikidot:authorName>				<wikidot:authorUserId>6812433</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>From what I read from the getKey page, it says it is only reset to 0 if you use it directly instead of storing it in a variable. I don't use it directly very often, and in both of these cases, I did not. But the thing that baffled me is that I got two different results testing the same key. When I was able to get the left arrow &quot;Held down&quot; during the first program, it returned G (getKey) as:<br /> 24,0,24,0,24,0,24,0,24,0,24,0,24,0,24,0,24,0,24,0,24,0,24,0,24,0,&#8230;.<br /> But when I did the second program..which I forgot to give the code for&#8230;.</p> <div class="code"> <pre><code>:ClrHome :Repeat G=105 :Lbl S :getKey -&gt; G :Output(8,1,G) :If G&lt;10 :Output(8,2,&quot; &quot;) [one space between &quot;s] :If G=0 :Then :Output(4,8,&quot;O&quot;) :Output(4,1,&quot; &quot;) :Output(1,8,&quot; &quot;) :Output(8,8,&quot; &quot;) :Output(4,16,&quot; &quot;) :Goto S :End :If G=24 :Then :Output(4,8,&quot; &quot;) :Output(4,1,&quot;O&quot;) :Goto S :End :If G=25 :Then :Output(4,8,&quot; &quot;) :Output(1,8,&quot;O&quot;) :Goto S :End :If G=26 :Then :Output(4,8,&quot; &quot;) :Output(4,16,&quot;O&quot;) :Goto S :End :If G=34 :Then :Output(4,8,&quot; &quot;) :Output(8,8,&quot;O&quot;) :Goto S :End :End :ClrHome</code></pre></div> <p>&#8230;I got<br /> 24,0,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24</p> <p>This doesn't seem to me like it has anything to do with it being reset to zero. Then again, I have no clue why these two programs got different results even though my methods were the same. So, I guess the part I'm really trying to figure out is why the two programs produced different results.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-13832494#post-4801966</guid>
				<title>Re: getKey Behavior and Mysteries</title>
				<link>http://tibasicdev.wikidot.com/forum/t-13832494/getkey-behavior-and-mysteries#post-4801966</link>
				<description></description>
				<pubDate>Fri, 23 Oct 2020 01:52:46 +0000</pubDate>
				<wikidot:authorName>J_Walker87</wikidot:authorName>				<wikidot:authorUserId>6818760</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Interesting results, Pixel Physics. I have developed several TI-BASIC games, and I would have to agree with CalcNerd's reply. As far as loopholes, I haven't found any. But, if you are developing games, the arrow keys are generally the best choice for several reasons, including the fact that the calculator continuously reads the value of getKey if it is one of the arrow keys.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-13832494#post-4801843</guid>
				<title>Re: getKey Behavior and Mysteries</title>
				<link>http://tibasicdev.wikidot.com/forum/t-13832494/getkey-behavior-and-mysteries#post-4801843</link>
				<description></description>
				<pubDate>Thu, 22 Oct 2020 19:57:21 +0000</pubDate>
				<wikidot:authorName>CalcNerd</wikidot:authorName>				<wikidot:authorUserId>6321217</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I'm no expert here, so don't quote me. I believe that the arrow keys and a few others have special functions that allow them to be held down. I don't think that I can really answer your question fully, and I'm sorry about that. I believe that when you use getKey it puts the value of zero back into the variable and if you would press it at the right time (not positive here). It says this on the getKey page &quot;The value of getKey is cleared every time you read from it, until a new key is pressed&quot;.</p> <p>Again, I am not sure about this, but you can look at the getKey page for more insight.</p> <p>Hope you can figure it out!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://tibasicdev.wikidot.com/forum/t-13832494#post-4801428</guid>
				<title>getKey Behavior and Mysteries</title>
				<link>http://tibasicdev.wikidot.com/forum/t-13832494/getkey-behavior-and-mysteries#post-4801428</link>
				<description></description>
				<pubDate>Thu, 22 Oct 2020 07:07:39 +0000</pubDate>
				<wikidot:authorName>Pixel Physics</wikidot:authorName>				<wikidot:authorUserId>6812433</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>So, I was just messing around with the getKey variable to see if I could find any loopholes for measuring multiple key presses or measuring if the key is being held down. I came across some strange things and was wondering if anyone could explain to me why the Ti operating system acts this way.</p> <p>So I started out with the most basic of programs to experiment on:</p> <div class="code"> <pre><code>:Repeat G=105 :getKey -&gt; G (-&gt; is the store symbol) :Disp G :End</code></pre></div> <p>What I found was that if you press a key down and hold it, it does not measure it more than one time. (This was done on a Ti-83+ and a Ti-84+ SE) But, if you press the key down a few times at the same rate as it is displaying G, and then hold it down immediately, it will measure it every other time it displays. (Note, this can take a while to achieve if you don't have quick fingers.) What makes this happen internally?</p> <p>The other observation I made was that with this program, if you press down a key and hold it, it will only measure it once. But, I made another program that uses output instead of disp to make a &quot;O&quot; move around the screen and output the key # in the corner. I found that when you hold the key down on this program, it measures it once, then measures 0, and then measures the key # for as long as the key is pressed. What makes this happen?</p> <p>As a game designer who wants to get the best from Ti-Basic in his programs, These things interest me. Not only because I am fascinated by code and programming, but also because there may be potential loopholes for better control in my programs and games. If anyone knows enough about this subject to help, I would greatly appreciate it. I will continue experimenting and researching and post more updates here if there are any.</p> <p>Thanks for reading!</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>