-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path539.html
More file actions
362 lines (362 loc) · 47.3 KB
/
Copy path539.html
File metadata and controls
362 lines (362 loc) · 47.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SmallBASIC | INKEY</title>
<meta name="description" content="Returns the last key-code in keyboard buffer, or an empty string if there are no keys. Special key-codes like the function-keys are returned as 2-byte string.">
<link rel="canonical" href="539">
<link rel="keywords" href="INKEY">
<link rel="stylesheet" href="/css/style.css">
<link rel="icon" type="image/png" href="/images/sb-desktop-32x32.png">
<script src="/clipboard.js"></script>
</head>
<body>
<button onclick="topFunction()" id="BackToTopBtn" title="Go to top">⯅</button>
<script src="/backtotop.js"></script>
<div class="wrapAll clearfix">
<nav class="navigation">
<div class="logo">
<a href="/"><img src='/images/sb-logo.png?v=2' alt="logo"></a>
</div>
<div class="navlinks">
<a href="/pages/download.html">Download</a>
<a href="/pages/news.html">News</a>
<a href="/pages/community.html">Community</a>
<a href="/pages/articles.html">Resources</a>
<a class='active' href="/pages/reference.html">Language Reference</a>
<a href="/pages/guide.html">SmallBASIC Manual</a>
</div>
</nav>
<div class="mainsection">
<div class="tabs clearfix">
<div class="tabsRight">
<a target="_github" href="https://github.com/smallbasic/smallbasic.github.io/blob/master/_build/reference/539-console-inkey.markdown">Edit</a>
<a target="_github" href="https://github.com/smallbasic/smallbasic.github.io/commits/master/_build/reference/539-console-inkey.markdown">History</a>
</div>
</div>
<div class="article">
<h1>INKEY</h1>
<blockquote>INKEY</blockquote>
<div class="siteSub">
<p>
<a href="/">Home</a> >
<a href="/pages/reference.html">Reference</a> >
<a href="/pages/console.html">Console</a>
</p>
</div>
<p>Returns the last key-code in keyboard buffer, or an empty string if
there are no keys. Special key-codes like the function-keys are returned
as 2-byte string.</p>
<h3 id="example-1">Example 1</h3>
<div class="sourceCode" id="cb1"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="kw">WHILE(</span><span class="dv">1</span>)</span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> k = <span class="kw">INKEY</span></span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a> <span class="kw">IF </span><span class="fu">LEN</span>(k)</span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a> <span class="kw">IF </span><span class="fu">LEN</span>(k)=<span class="dv">2</span></span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a> ? <span class="st">"H/W #"</span>+<span class="fu">ASC</span>(<span class="fu">RIGHT</span>(k,<span class="dv">1</span>))</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a> <span class="kw">ELSE</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a> ? k; <span class="st">" "</span>; <span class="fu">ASC</span>(k)</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a> <span class="kw">FI</span></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a> <span class="kw">FI</span></span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">SHOWPAGE</span></span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a><span class="kw">WEND</span></span></code></pre></div>
<h3 id="example-2">Example 2</h3>
<p>The following program will return the keycode and a string for every
pressed key. The string can be used in an if-statement to querry if the
key was pressed. See example 3 how to use the string.</p>
<div class="sourceCode" id="cb2"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="kw">while(</span><span class="dv">1</span>)</span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a> k = <span class="kw">INKEY</span></span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a> <span class="kw">if </span><span class="fu">len</span>(k)</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a> <span class="kw">if </span><span class="fu">len</span>(k) == <span class="dv">2</span> </span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a> <span class="kw">print</span> <span class="st">"2-Byte key code : "</span> + <span class="fu">asc</span>(<span class="fu">mid</span>(k,<span class="dv">1</span>,<span class="dv">1</span>)) + <span class="st">" "</span> + <span class="fu">asc</span>(<span class="fu">mid</span>(k,<span class="dv">2</span>,<span class="dv">1</span>));</span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a> <span class="kw">print</span> <span class="st">" -> s = chr("</span>;<span class="fu">asc</span>(<span class="fu">mid</span>(k,<span class="dv">1</span>,<span class="dv">1</span>));<span class="st">") + chr("</span>;<span class="fu">asc</span>(<span class="fu">mid</span>(k,<span class="dv">2</span>,<span class="dv">1</span>));<span class="st">")"</span> </span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a> <span class="kw">else</span></span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="kw">if(</span><span class="fu">asc</span>(k) > <span class="dv">37</span>)</span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> <span class="kw">print</span> <span class="st">"Printable key code: "</span>; <span class="fu">asc</span>(k); <span class="st">" -> s = \"";k;"</span>\<span class="st">""</span> </span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="kw">else</span></span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a> <span class="kw">print</span> <span class="st">"1-Byte key code : "</span>; <span class="fu">asc</span>(k);</span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a> <span class="kw">print</span> <span class="st">" -> s = chr("</span>;<span class="fu">asc</span>(k);<span class="st">")"</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a> <span class="kw">endif</span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a> <span class="kw">endif</span></span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> <span class="kw">endif</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">showpage</span></span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a><span class="kw">wend</span></span></code></pre></div>
<h3 id="example-3-querry-if-a-key-was-pressed">Example 3: Querry if a
key was pressed</h3>
<p>See example 2 to get the keycodes for the keys.</p>
<div class="sourceCode" id="cb3"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="dt">const</span> KeyUp = <span class="fu">chr</span>(<span class="dv">27</span>) + <span class="fu">chr</span>(<span class="dv">9</span>)</span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="dt">const</span> KeyDown = <span class="fu">chr</span>(<span class="dv">27</span>) + <span class="fu">chr</span>(<span class="dv">10</span>)</span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a><span class="dt">const</span> KeySpace = <span class="st">" "</span></span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a><span class="dt">const</span> KeyEsc = <span class="fu">chr</span>(<span class="dv">27</span>)</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a><span class="dt">const</span> KeyReturn = <span class="fu">chr</span>(<span class="dv">13</span>)</span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-7"><a href="#cb3-7" aria-hidden="true" tabindex="-1"></a><span class="kw">while(</span><span class="dv">1</span>)</span>
<span id="cb3-8"><a href="#cb3-8" aria-hidden="true" tabindex="-1"></a> k = <span class="kw">INKEY</span></span>
<span id="cb3-9"><a href="#cb3-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-10"><a href="#cb3-10" aria-hidden="true" tabindex="-1"></a> <span class="kw">if </span><span class="fu">len</span>(k)</span>
<span id="cb3-11"><a href="#cb3-11" aria-hidden="true" tabindex="-1"></a> <span class="kw">select case </span>k</span>
<span id="cb3-12"><a href="#cb3-12" aria-hidden="true" tabindex="-1"></a> <span class="kw">case</span> KeyUp: <span class="kw">print</span> <span class="st">"Up"</span></span>
<span id="cb3-13"><a href="#cb3-13" aria-hidden="true" tabindex="-1"></a> <span class="kw">case</span> KeyDown: <span class="kw">print</span> <span class="st">"Down"</span></span>
<span id="cb3-14"><a href="#cb3-14" aria-hidden="true" tabindex="-1"></a> <span class="kw">case</span> KeySpace: <span class="kw">print</span> <span class="st">"Space"</span></span>
<span id="cb3-15"><a href="#cb3-15" aria-hidden="true" tabindex="-1"></a> <span class="kw">case</span> KeyEsc: <span class="kw">print</span> <span class="st">"Esc"</span></span>
<span id="cb3-16"><a href="#cb3-16" aria-hidden="true" tabindex="-1"></a> <span class="kw">case</span> KeyReturn: <span class="kw">print</span> <span class="st">"Return"</span></span>
<span id="cb3-17"><a href="#cb3-17" aria-hidden="true" tabindex="-1"></a> <span class="kw">case</span> <span class="st">"a"</span>: <span class="kw">print</span> <span class="st">"a"</span></span>
<span id="cb3-18"><a href="#cb3-18" aria-hidden="true" tabindex="-1"></a> <span class="kw">case</span> <span class="st">"A"</span>: <span class="kw">print</span> <span class="st">"A"</span></span>
<span id="cb3-19"><a href="#cb3-19" aria-hidden="true" tabindex="-1"></a> <span class="kw">case</span> <span class="kw">else</span>: <span class="kw">print</span> <span class="st">"other key"</span></span>
<span id="cb3-20"><a href="#cb3-20" aria-hidden="true" tabindex="-1"></a> <span class="kw">end select</span></span>
<span id="cb3-21"><a href="#cb3-21" aria-hidden="true" tabindex="-1"></a> <span class="kw">endif</span></span>
<span id="cb3-22"><a href="#cb3-22" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb3-23"><a href="#cb3-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">showpage</span></span>
<span id="cb3-24"><a href="#cb3-24" aria-hidden="true" tabindex="-1"></a><span class="kw">wend</span></span></code></pre></div>
<h3 id="example-4-input-form">Example 4: Input form</h3>
<div class="sourceCode" id="cb4"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a><span class="co">' Key values:</span></span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_BKSP = <span class="fu">Chr</span>(<span class="dv">0x08</span>) <span class="co">' BackSpace</span></span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_TAB = <span class="fu">Chr</span>(<span class="dv">0x09</span>)</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_ENTER = <span class="fu">Chr</span>(<span class="dv">0x0D</span>)</span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_ESC = <span class="fu">Chr</span>(<span class="dv">0x1B</span>) <span class="co">' Escape</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_DELETE = <span class="fu">Chr</span>(<span class="dv">0x7F</span>)</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_PGUP = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x01</span>) <span class="co">' Page Up</span></span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_PGDN = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x02</span>) <span class="co">' Page Down</span></span>
<span id="cb4-9"><a href="#cb4-9" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_LEFT = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x04</span>) <span class="co">' Arrow Left</span></span>
<span id="cb4-10"><a href="#cb4-10" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_RIGHT = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x05</span>) <span class="co">' Arrow Right</span></span>
<span id="cb4-11"><a href="#cb4-11" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_UP = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x09</span>) <span class="co">' Arrow Up</span></span>
<span id="cb4-12"><a href="#cb4-12" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_DOWN = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x0A</span>) <span class="co">' Arrow Down</span></span>
<span id="cb4-13"><a href="#cb4-13" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_INSERT = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x10</span>)</span>
<span id="cb4-14"><a href="#cb4-14" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_HOME = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x11</span>)</span>
<span id="cb4-15"><a href="#cb4-15" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> K_END = K_ESC + <span class="fu">Chr</span>(<span class="dv">0x12</span>)</span>
<span id="cb4-16"><a href="#cb4-16" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-17"><a href="#cb4-17" aria-hidden="true" tabindex="-1"></a><span class="co">' Edit string:</span></span>
<span id="cb4-18"><a href="#cb4-18" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> edit_char(txt, pos, char, ins_mode) = <span class="fu">Replace</span>(txt, pos, char, ins_mode = <span class="dv">0</span>)</span>
<span id="cb4-19"><a href="#cb4-19" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> delete_char(txt, pos) = <span class="fu">Replace</span>(txt, pos, <span class="st">""</span>, <span class="dv">1</span>)</span>
<span id="cb4-20"><a href="#cb4-20" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-21"><a href="#cb4-21" aria-hidden="true" tabindex="-1"></a><span class="co">' Initialize three demo fields:</span></span>
<span id="cb4-22"><a href="#cb4-22" aria-hidden="true" tabindex="-1"></a>f_lbl = [<span class="st">"First Name:"</span>, <span class="st">"Last Name: "</span>, <span class="st">"Your Hobby:"</span>] <span class="co">' field label</span></span>
<span id="cb4-23"><a href="#cb4-23" aria-hidden="true" tabindex="-1"></a>f_row = [<span class="dv">3</span>, <span class="dv">5</span>, <span class="dv">7</span>] <span class="co">' label row</span></span>
<span id="cb4-24"><a href="#cb4-24" aria-hidden="true" tabindex="-1"></a>f_col = [<span class="dv">1</span>, <span class="dv">1</span>, <span class="dv">1</span>] <span class="co">' label column</span></span>
<span id="cb4-25"><a href="#cb4-25" aria-hidden="true" tabindex="-1"></a>f_len = [<span class="dv">10</span>, <span class="dv">10</span>, <span class="dv">20</span>] <span class="co">' variable length</span></span>
<span id="cb4-26"><a href="#cb4-26" aria-hidden="true" tabindex="-1"></a>f_var = [<span class="st">""</span>, <span class="st">""</span>, <span class="st">""</span>] <span class="co">' variable value</span></span>
<span id="cb4-27"><a href="#cb4-27" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-28"><a href="#cb4-28" aria-hidden="true" tabindex="-1"></a><span class="co">' Index of fields:</span></span>
<span id="cb4-29"><a href="#cb4-29" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> MIN_IX = <span class="fu">Lbound</span>(f_lbl)</span>
<span id="cb4-30"><a href="#cb4-30" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> MAX_IX = <span class="fu">Ubound</span>(f_lbl)</span>
<span id="cb4-31"><a href="#cb4-31" aria-hidden="true" tabindex="-1"></a>ix = MIN_IX <span class="co">' Start on first field index</span></span>
<span id="cb4-32"><a href="#cb4-32" aria-hidden="true" tabindex="-1"></a>ins_mode = <span class="dv">1</span> <span class="co">' Start in insert character mode</span></span>
<span id="cb4-33"><a href="#cb4-33" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-34"><a href="#cb4-34" aria-hidden="true" tabindex="-1"></a><span class="co">' Main demo loop:</span></span>
<span id="cb4-35"><a href="#cb4-35" aria-hidden="true" tabindex="-1"></a><span class="kw">While </span><span class="dt">True</span></span>
<span id="cb4-36"><a href="#cb4-36" aria-hidden="true" tabindex="-1"></a> <span class="co">' Update variables:</span></span>
<span id="cb4-37"><a href="#cb4-37" aria-hidden="true" tabindex="-1"></a> eol = <span class="fu">Len</span>(f_var(ix)) + <span class="dv">1</span> <span class="co">' End Of Line</span></span>
<span id="cb4-38"><a href="#cb4-38" aria-hidden="true" tabindex="-1"></a> <span class="kw">If </span>pos > eol <span class="kw">Or</span> pos < <span class="dv">1</span> <span class="kw">Then po</span>s = eol <span class="co">' Adjust cursor pos on new field</span></span>
<span id="cb4-39"><a href="#cb4-39" aria-hidden="true" tabindex="-1"></a> <span class="co">' Update screen:</span></span>
<span id="cb4-40"><a href="#cb4-40" aria-hidden="true" tabindex="-1"></a> <span class="kw">For </span>i = MIN_IX <span class="kw">To</span> MAX_IX</span>
<span id="cb4-41"><a href="#cb4-41" aria-hidden="true" tabindex="-1"></a> <span class="co">' Print all fields:</span></span>
<span id="cb4-42"><a href="#cb4-42" aria-hidden="true" tabindex="-1"></a> s = <span class="fu">Cat</span>(<span class="dv">0</span>) + f_lbl(i) + <span class="st">" "</span></span>
<span id="cb4-43"><a href="#cb4-43" aria-hidden="true" tabindex="-1"></a> s += <span class="fu">Cat</span>(<span class="dv">3</span>) + f_var(i) + <span class="fu">Spc</span>(f_len(i) - <span class="fu">Len</span>(f_var(i))) + <span class="st">" "</span> <span class="co">' + eol</span></span>
<span id="cb4-44"><a href="#cb4-44" aria-hidden="true" tabindex="-1"></a> <span class="fu">Locate</span> f_row(i), f_col(i)</span>
<span id="cb4-45"><a href="#cb4-45" aria-hidden="true" tabindex="-1"></a> <span class="kw">Print</span> s + <span class="fu">Cat</span>(<span class="dv">0</span>);</span>
<span id="cb4-46"><a href="#cb4-46" aria-hidden="true" tabindex="-1"></a> <span class="co">' Print the cursor:</span></span>
<span id="cb4-47"><a href="#cb4-47" aria-hidden="true" tabindex="-1"></a> <span class="kw">If </span>i = ix <span class="kw">Then</span></span>
<span id="cb4-48"><a href="#cb4-48" aria-hidden="true" tabindex="-1"></a> <span class="kw">If Not</span> ins_mode <span class="kw">Then Co</span>lor <span class="dv">15</span></span>
<span id="cb4-49"><a href="#cb4-49" aria-hidden="true" tabindex="-1"></a> <span class="fu">Locate</span> f_row(i), f_col(i) + <span class="fu">Len</span>(f_lbl(i)) + pos</span>
<span id="cb4-50"><a href="#cb4-50" aria-hidden="true" tabindex="-1"></a> <span class="kw">Print</span> <span class="fu">Cat</span>(<span class="dv">2</span>) + <span class="fu">Mid</span>(f_var(i) + <span class="st">" "</span>, pos, <span class="dv">1</span>); <span class="co">' (+ " " for eol)</span></span>
<span id="cb4-51"><a href="#cb4-51" aria-hidden="true" tabindex="-1"></a> <span class="kw">Fi</span></span>
<span id="cb4-52"><a href="#cb4-52" aria-hidden="true" tabindex="-1"></a> <span class="kw">Next </span>i</span>
<span id="cb4-53"><a href="#cb4-53" aria-hidden="true" tabindex="-1"></a> <span class="co">' Update status line:</span></span>
<span id="cb4-54"><a href="#cb4-54" aria-hidden="true" tabindex="-1"></a> s = <span class="st">" (Esc=Stop) | "</span> + <span class="kw">Iff</span>(ins_mode, <span class="st">"Insert "</span>, <span class="st">"Replace"</span>) + <span class="fu">Spc</span>(<span class="dv">3</span>)</span>
<span id="cb4-55"><a href="#cb4-55" aria-hidden="true" tabindex="-1"></a> s += <span class="fu">Format</span>(<span class="st">"| 00:"</span>, ix) + <span class="kw">Iff</span>(pos = eol, <span class="st">"EOL"</span>, <span class="fu">Format</span>(<span class="st">"000"</span>, pos)) + <span class="fu">Spc</span>(<span class="dv">1</span>)</span>
<span id="cb4-56"><a href="#cb4-56" aria-hidden="true" tabindex="-1"></a> <span class="fu">Locate</span> <span class="dv">0</span>, <span class="dv">0</span>: <span class="kw">Print</span> <span class="fu">Cat</span>(<span class="dv">0</span>) + <span class="fu">Cat</span>(<span class="dv">3</span>) + s;</span>
<span id="cb4-57"><a href="#cb4-57" aria-hidden="true" tabindex="-1"></a> <span class="fu">Showpage</span> <span class="co">' SHOWPAGE makes INKEY works smoother (using SB 0.12.2)</span></span>
<span id="cb4-58"><a href="#cb4-58" aria-hidden="true" tabindex="-1"></a> <span class="co">' Wait for a key:</span></span>
<span id="cb4-59"><a href="#cb4-59" aria-hidden="true" tabindex="-1"></a> <span class="kw">Repeat</span>: key = <span class="kw">Inkey</span></span>
<span id="cb4-60"><a href="#cb4-60" aria-hidden="true" tabindex="-1"></a> <span class="kw">Until </span>key <> <span class="st">""</span></span>
<span id="cb4-61"><a href="#cb4-61" aria-hidden="true" tabindex="-1"></a> <span class="co">' Check key:</span></span>
<span id="cb4-62"><a href="#cb4-62" aria-hidden="true" tabindex="-1"></a> <span class="kw">Select Case </span>key</span>
<span id="cb4-63"><a href="#cb4-63" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_ESC: <span class="kw">Stop</span></span>
<span id="cb4-64"><a href="#cb4-64" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_INSERT: ins_mode = <span class="kw">Not</span> ins_mode</span>
<span id="cb4-65"><a href="#cb4-65" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_ENTER, K_TAB: ix++: <span class="kw">If </span>ix > MAX_IX <span class="kw">Then ix</span> = MIN_IX</span>
<span id="cb4-66"><a href="#cb4-66" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_DOWN: <span class="kw">If </span>ix < MAX_IX <span class="kw">Then ix</span>++</span>
<span id="cb4-67"><a href="#cb4-67" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_UP: <span class="kw">If </span>ix > MIN_IX <span class="kw">Then ix</span>--</span>
<span id="cb4-68"><a href="#cb4-68" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_PGDN: ix = MAX_IX</span>
<span id="cb4-69"><a href="#cb4-69" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_PGUP: ix = MIN_IX</span>
<span id="cb4-70"><a href="#cb4-70" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_HOME: pos = <span class="dv">1</span></span>
<span id="cb4-71"><a href="#cb4-71" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_END: pos = eol</span>
<span id="cb4-72"><a href="#cb4-72" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_LEFT: <span class="kw">If </span>pos > <span class="dv">1</span> <span class="kw">Then po</span>s--</span>
<span id="cb4-73"><a href="#cb4-73" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_RIGHT: <span class="kw">If </span>pos < eol <span class="kw">Then po</span>s++</span>
<span id="cb4-74"><a href="#cb4-74" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_DELETE: <span class="kw">If </span>pos < eol <span class="kw">Then f_</span>var(ix) = delete_char(f_var(ix), pos)</span>
<span id="cb4-75"><a href="#cb4-75" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> K_BKSP: <span class="kw">If </span>pos > <span class="dv">1</span> <span class="kw">Then po</span>s--: f_var(ix) = delete_char(f_var(ix), pos)</span>
<span id="cb4-76"><a href="#cb4-76" aria-hidden="true" tabindex="-1"></a> <span class="kw">Case</span> <span class="kw">Else</span></span>
<span id="cb4-77"><a href="#cb4-77" aria-hidden="true" tabindex="-1"></a> <span class="kw">If </span><span class="fu">Len</span>(key) = <span class="dv">1</span> <span class="kw">And</span> <span class="fu">Asc</span>(key) >= <span class="dv">32</span> <span class="kw">Then</span> <span class="co">' Regular character?</span></span>
<span id="cb4-78"><a href="#cb4-78" aria-hidden="true" tabindex="-1"></a> ins = ins_mode <span class="kw">And</span> (<span class="fu">Len</span>(f_var(ix)) < f_len(ix)) <span class="co">' Insert mode</span></span>
<span id="cb4-79"><a href="#cb4-79" aria-hidden="true" tabindex="-1"></a> rep = (<span class="kw">Not</span> ins_mode) <span class="kw">And</span> (pos <= f_len(ix)) <span class="co">' Replace mode</span></span>
<span id="cb4-80"><a href="#cb4-80" aria-hidden="true" tabindex="-1"></a> <span class="kw">If </span>ins <span class="kw">Or</span> rep <span class="kw">Then</span></span>
<span id="cb4-81"><a href="#cb4-81" aria-hidden="true" tabindex="-1"></a> f_var(ix) = edit_char(f_var(ix), pos, key, ins_mode)</span>
<span id="cb4-82"><a href="#cb4-82" aria-hidden="true" tabindex="-1"></a> pos++ <span class="co">' Move cursor to next character</span></span>
<span id="cb4-83"><a href="#cb4-83" aria-hidden="true" tabindex="-1"></a> <span class="kw">Fi</span></span>
<span id="cb4-84"><a href="#cb4-84" aria-hidden="true" tabindex="-1"></a> <span class="kw">Fi</span></span>
<span id="cb4-85"><a href="#cb4-85" aria-hidden="true" tabindex="-1"></a> <span class="kw">End Select</span></span>
<span id="cb4-86"><a href="#cb4-86" aria-hidden="true" tabindex="-1"></a><span class="kw">Wend</span></span></code></pre></div>
<h3 id="example-5-a-basic-key-code-unit">Example 5: A basic key code
UNIT</h3>
<div class="sourceCode" id="cb5"><pre
class="sourceCode smallbasic"><code class="sourceCode smallbasic"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a><span class="co">REM Language: SmallBASIC 0.12.6 (Linux 32-bit)</span></span>
<span id="cb5-2"><a href="#cb5-2" aria-hidden="true" tabindex="-1"></a><span class="co">REM Purpose: Special key values returned by INKEY.</span></span>
<span id="cb5-3"><a href="#cb5-3" aria-hidden="true" tabindex="-1"></a><span class="co">REM (Values returned by INKEY cannot be used for DEFINEKEY).</span></span>
<span id="cb5-4"><a href="#cb5-4" aria-hidden="true" tabindex="-1"></a><span class="co">REM File name: key.bas</span></span>
<span id="cb5-5"><a href="#cb5-5" aria-hidden="true" tabindex="-1"></a><span class="co">REM Unit name: key</span></span>
<span id="cb5-6"><a href="#cb5-6" aria-hidden="true" tabindex="-1"></a><span class="co">REM Version: 1.0.0 24/05/2016</span></span>
<span id="cb5-7"><a href="#cb5-7" aria-hidden="true" tabindex="-1"></a><span class="co">REM Author: shian</span></span>
<span id="cb5-8"><a href="#cb5-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-9"><a href="#cb5-9" aria-hidden="true" tabindex="-1"></a><span class="co">' --- Start demo code ------------------------------------</span></span>
<span id="cb5-10"><a href="#cb5-10" aria-hidden="true" tabindex="-1"></a><span class="co">'</span></span>
<span id="cb5-11"><a href="#cb5-11" aria-hidden="true" tabindex="-1"></a><span class="co">'Import key</span></span>
<span id="cb5-12"><a href="#cb5-12" aria-hidden="true" tabindex="-1"></a><span class="co">'</span></span>
<span id="cb5-13"><a href="#cb5-13" aria-hidden="true" tabindex="-1"></a><span class="co">'? "Press Escape to stop..."</span></span>
<span id="cb5-14"><a href="#cb5-14" aria-hidden="true" tabindex="-1"></a><span class="co">'Repeat: k = Inkey</span></span>
<span id="cb5-15"><a href="#cb5-15" aria-hidden="true" tabindex="-1"></a><span class="co">' Select Case k</span></span>
<span id="cb5-16"><a href="#cb5-16" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.ENTER : ? "Key.ENTER"</span></span>
<span id="cb5-17"><a href="#cb5-17" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.TABK : ? "Key.TABK"</span></span>
<span id="cb5-18"><a href="#cb5-18" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.CLICK : ? "Key.CLICK"</span></span>
<span id="cb5-19"><a href="#cb5-19" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.FN(1) : ? "Key.FN(1)"</span></span>
<span id="cb5-20"><a href="#cb5-20" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.FN(12) : ? "Key.FN(12)"</span></span>
<span id="cb5-21"><a href="#cb5-21" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.CTRL("A"): ? "Key.CTRL(a)"</span></span>
<span id="cb5-22"><a href="#cb5-22" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.ALT("A") : ? "Key.ALT(a)"</span></span>
<span id="cb5-23"><a href="#cb5-23" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.CTRL(Key.Enter) : ? "Key.CTRL(Key.Enter)"</span></span>
<span id="cb5-24"><a href="#cb5-24" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.ALT(Key.Enter) : ? "Key.ALT(Key.Enter)"</span></span>
<span id="cb5-25"><a href="#cb5-25" aria-hidden="true" tabindex="-1"></a><span class="co">' Case Key.SHIFT(Key.Enter): ? "Key.SHIFT(Key.Enter)"</span></span>
<span id="cb5-26"><a href="#cb5-26" aria-hidden="true" tabindex="-1"></a><span class="co">' End Select</span></span>
<span id="cb5-27"><a href="#cb5-27" aria-hidden="true" tabindex="-1"></a><span class="co">'Until k = Key.ESC</span></span>
<span id="cb5-28"><a href="#cb5-28" aria-hidden="true" tabindex="-1"></a><span class="co">'</span></span>
<span id="cb5-29"><a href="#cb5-29" aria-hidden="true" tabindex="-1"></a><span class="co">' --- End demo code ------------------------------------</span></span>
<span id="cb5-30"><a href="#cb5-30" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-31"><a href="#cb5-31" aria-hidden="true" tabindex="-1"></a><span class="pp">Unit</span> key</span>
<span id="cb5-32"><a href="#cb5-32" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-33"><a href="#cb5-33" aria-hidden="true" tabindex="-1"></a><span class="co">' Useful Constants:</span></span>
<span id="cb5-34"><a href="#cb5-34" aria-hidden="true" tabindex="-1"></a><span class="pp">Export</span> BKSP, TABK, ENTER, ESC, BLANK, DEL</span>
<span id="cb5-35"><a href="#cb5-35" aria-hidden="true" tabindex="-1"></a><span class="pp">Export</span> PGUP, PGDN, LEFTK, RIGHTK, UP, DOWN </span>
<span id="cb5-36"><a href="#cb5-36" aria-hidden="true" tabindex="-1"></a><span class="pp">Export</span> INS, HOMEK, ENDK, CLICK</span>
<span id="cb5-37"><a href="#cb5-37" aria-hidden="true" tabindex="-1"></a><span class="co">' Useful Functions:</span></span>
<span id="cb5-38"><a href="#cb5-38" aria-hidden="true" tabindex="-1"></a><span class="pp">Export</span> FN, CTRL, ALT, SHIFT</span>
<span id="cb5-39"><a href="#cb5-39" aria-hidden="true" tabindex="-1"></a><span class="pp">Export</span> CTRL_ALT, ALT_SHIFT, CTRL_SHIFT <span class="co">' (used by system)</span></span>
<span id="cb5-40"><a href="#cb5-40" aria-hidden="true" tabindex="-1"></a><span class="co">' The left character of INKEY (Useful only for special cases):</span></span>
<span id="cb5-41"><a href="#cb5-41" aria-hidden="true" tabindex="-1"></a><span class="pp">Export</span> CTRL_CHR, ALT_CHR, SHIFT_CHR</span>
<span id="cb5-42"><a href="#cb5-42" aria-hidden="true" tabindex="-1"></a><span class="pp">Export</span> CTRL_ALT_CHR, ALT_SHIFT_CHR, CTRL_SHIFT_CHR</span>
<span id="cb5-43"><a href="#cb5-43" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-44"><a href="#cb5-44" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> CTRL_CHR = <span class="fu">Chr</span>(<span class="dv">0x01</span>) <span class="co">' for Ctrl+Char</span></span>
<span id="cb5-45"><a href="#cb5-45" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> ALT_CHR = <span class="fu">Chr</span>(<span class="dv">0x02</span>) <span class="co">' for Alt+Char</span></span>
<span id="cb5-46"><a href="#cb5-46" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> SHIFT_CHR = <span class="fu">Chr</span>(<span class="dv">0x03</span>) <span class="co">' for Shift+Char</span></span>
<span id="cb5-47"><a href="#cb5-47" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> CTRL_ALT_CHR = <span class="fu">Chr</span>(<span class="dv">0x04</span>) <span class="co">' for Ctrl+Alt+Char (used by system)</span></span>
<span id="cb5-48"><a href="#cb5-48" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> ALT_SHIFT_CHR = <span class="fu">Chr</span>(<span class="dv">0x05</span>) <span class="co">' for Alt+Shift+Char (used by system)</span></span>
<span id="cb5-49"><a href="#cb5-49" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> CTRL_SHIFT_CHR = <span class="fu">Chr</span>(<span class="dv">0x06</span>) <span class="co">' for Ctrl+Shift+Char (used by system)</span></span>
<span id="cb5-50"><a href="#cb5-50" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> BKSP = <span class="fu">Chr</span>(<span class="dv">0x08</span>) <span class="co">' BackSpace</span></span>
<span id="cb5-51"><a href="#cb5-51" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> TABK = <span class="fu">Chr</span>(<span class="dv">0x09</span>) <span class="co">' Tab key</span></span>
<span id="cb5-52"><a href="#cb5-52" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> ENTER = <span class="fu">Chr</span>(<span class="dv">0x0D</span>)</span>
<span id="cb5-53"><a href="#cb5-53" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> ESC = <span class="fu">Chr</span>(<span class="dv">0x1B</span>) <span class="co">' Escape</span></span>
<span id="cb5-54"><a href="#cb5-54" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> BLANK = <span class="fu">Chr</span>(<span class="dv">0x20</span>) <span class="co">' Space key</span></span>
<span id="cb5-55"><a href="#cb5-55" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> DEL = <span class="fu">Chr</span>(<span class="dv">0x7F</span>) <span class="co">' Delete</span></span>
<span id="cb5-56"><a href="#cb5-56" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> PGUP = ESC + <span class="fu">Chr</span>(<span class="dv">0x01</span>) <span class="co">' Page Up</span></span>
<span id="cb5-57"><a href="#cb5-57" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> PGDN = ESC + <span class="fu">Chr</span>(<span class="dv">0x02</span>) <span class="co">' Page Down</span></span>
<span id="cb5-58"><a href="#cb5-58" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> LEFTK = ESC + <span class="fu">Chr</span>(<span class="dv">0x04</span>) <span class="co">' Arrow Left key</span></span>
<span id="cb5-59"><a href="#cb5-59" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> RIGHTK = ESC + <span class="fu">Chr</span>(<span class="dv">0x05</span>) <span class="co">' Arrow Right key</span></span>
<span id="cb5-60"><a href="#cb5-60" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> UP = ESC + <span class="fu">Chr</span>(<span class="dv">0x09</span>) <span class="co">' Arrow Up</span></span>
<span id="cb5-61"><a href="#cb5-61" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> DOWN = ESC + <span class="fu">Chr</span>(<span class="dv">0x0A</span>) <span class="co">' Arrow Down</span></span>
<span id="cb5-62"><a href="#cb5-62" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> INS = ESC + <span class="fu">Chr</span>(<span class="dv">0x10</span>) <span class="co">' Insert</span></span>
<span id="cb5-63"><a href="#cb5-63" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> HOMEK = ESC + <span class="fu">Chr</span>(<span class="dv">0x11</span>) <span class="co">' Home key</span></span>
<span id="cb5-64"><a href="#cb5-64" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> ENDK = ESC + <span class="fu">Chr</span>(<span class="dv">0x12</span>) <span class="co">' End key</span></span>
<span id="cb5-65"><a href="#cb5-65" aria-hidden="true" tabindex="-1"></a><span class="dt">Const</span> CLICK = ESC + <span class="fu">Chr</span>(<span class="dv">0xC0</span>) <span class="co">' Left Mouse Button Click</span></span>
<span id="cb5-66"><a href="#cb5-66" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> FN(n) = ESC + <span class="fu">Chr</span>(<span class="dv">0xF0</span> + n) <span class="co">' FN(1) is F1 (up to 12).</span></span>
<span id="cb5-67"><a href="#cb5-67" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> CTRL(c) = CTRL_CHR + <span class="fu">Lcase</span>(c) <span class="co">' Ctrl+a, Ctrl+Enter, etc</span></span>
<span id="cb5-68"><a href="#cb5-68" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> ALT(c) = ALT_CHR + <span class="fu">Lcase</span>(c) <span class="co">' Alt+a, Alt+Enter, etc</span></span>
<span id="cb5-69"><a href="#cb5-69" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> SHIFT(c) = SHIFT_CHR + c <span class="co">' Shift+Enter, Shift+Tab, etc</span></span>
<span id="cb5-70"><a href="#cb5-70" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-71"><a href="#cb5-71" aria-hidden="true" tabindex="-1"></a><span class="co">' These are system shortcuts - so it's advisable NOT to use them at all!</span></span>
<span id="cb5-72"><a href="#cb5-72" aria-hidden="true" tabindex="-1"></a><span class="co">' (however, it's possible to detect them when not used by the system).</span></span>
<span id="cb5-73"><a href="#cb5-73" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> CTRL_ALT(c) = CTRL_ALT_CHR + <span class="fu">Lcase</span>(c) <span class="co">' Ctrl+Alt+a, etc</span></span>
<span id="cb5-74"><a href="#cb5-74" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> ALT_SHIFT(c) = ALT_SHIFT_CHR + <span class="fu">Lcase</span>(c) <span class="co">' Alt+Shift+a, etc</span></span>
<span id="cb5-75"><a href="#cb5-75" aria-hidden="true" tabindex="-1"></a><span class="kw">Def</span> CTRL_SHIFT(c) = CTRL_SHIFT_CHR + <span class="fu">Lcase</span>(c) <span class="co">' Ctrl+Shift+a, etc</span></span>
<span id="cb5-76"><a href="#cb5-76" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb5-77"><a href="#cb5-77" aria-hidden="true" tabindex="-1"></a><span class="co">' ' Use this code to test and print key codes as hexa:</span></span>
<span id="cb5-78"><a href="#cb5-78" aria-hidden="true" tabindex="-1"></a><span class="co">' ' --------------------------------------------------</span></span>
<span id="cb5-79"><a href="#cb5-79" aria-hidden="true" tabindex="-1"></a><span class="co">' Print "Press Ctrl+B to stop..."</span></span>
<span id="cb5-80"><a href="#cb5-80" aria-hidden="true" tabindex="-1"></a><span class="co">' While 1: k = Inkey: l = Len(k)</span></span>
<span id="cb5-81"><a href="#cb5-81" aria-hidden="true" tabindex="-1"></a><span class="co">' If l Then</span></span>
<span id="cb5-82"><a href="#cb5-82" aria-hidden="true" tabindex="-1"></a><span class="co">' ? "0x"; Right("00" + Hex(Asc(k)), 2);</span></span>
<span id="cb5-83"><a href="#cb5-83" aria-hidden="true" tabindex="-1"></a><span class="co">' If l = 2 Then ? Right("00" + Hex(Asc(Mid(k, 2))), 2);</span></span>
<span id="cb5-84"><a href="#cb5-84" aria-hidden="true" tabindex="-1"></a><span class="co">' Print</span></span>
<span id="cb5-85"><a href="#cb5-85" aria-hidden="true" tabindex="-1"></a><span class="co">' Fi</span></span>
<span id="cb5-86"><a href="#cb5-86" aria-hidden="true" tabindex="-1"></a><span class="co">' Wend</span></span></code></pre></div>
<div class="lavenderBox">
<div class="header">Code samples using INKEY</div>
<div class="linklist">
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/3d wire cube v1.bas">3d wire cube v1.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/3d wire cube.bas">3d wire cube.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/3d_palmx.bas">3d_palmx.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/4tune.bas">4tune.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/mechanics/amortig.bas">amortig.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 1/anball 1.0.bas">anball 1.0.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/autumn scene.bas">autumn scene.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/BestOf Graphics/B+B.bas">B+B.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/Ball.bas">Ball.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/balls in 3d cube.bas">balls in 3d cube.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/balls.bas">balls.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/BestOf Graphics/bb2fork smurf.bas">bb2fork smurf.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 2/bezier's autograph book.bas">bezier's autograph book.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/bezier_pen.bas">bezier_pen.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/block.bas">block.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/games 3/bolmo.bas">bolmo.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/bonkers.bas">bonkers.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/bpf1.bas">bpf1.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/bpf2.bas">bpf2.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Peter Graphics/bubbles and triangles.bas">bubbles and triangles.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/applications/calc.bas">calc.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/utilities/character map.bas">character map.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Peter Graphics/circle trap.bas">circle trap.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/circles Kalide v2.bas">circles Kalide v2.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/applications/clock.bas">clock.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 4/clock.bas">clock.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/color chart.bas">color chart.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/misc/Other graphics/crop circles 1.bas">crop circles 1.bas </a>
<a target="_github" href="https://raw.githubusercontent.com/smallbasic/smallbasic.samples/master/graphics 1/cube3d.bas">cube3d.bas </a>
</div>
</div>
<div class="lavenderBox">
<div class="header">Console</div>
<div class="linklist">
<a href="/reference/521.html">AT </a>
<a href="/reference/522.html">BEEP </a>
<a href="/reference/538.html">CAT </a>
<a href="/reference/524.html">CLS </a>
<a href="/reference/1015.html">DEFINEKEY </a>
<a href="/reference/525.html">FORM </a>
<a href="/reference/539.html"><strong>INKEY</strong> </a>
<a href="/reference/527.html">INPUT </a>
<a href="/reference/528.html">LINEINPUT </a>
<a href="/reference/529.html">LINPUT </a>
<a href="/reference/530.html">LOCATE </a>
<a href="/reference/531.html">LOGPRINT </a>
<a href="/reference/532.html">NOSOUND </a>
<a href="/reference/533.html">PEN </a>
<a href="/reference/534.html">PLAY </a>
<a href="/reference/535.html">PRINT </a>
<a href="/reference/536.html">SOUND </a>
<a href="/reference/540.html">TAB </a>
</div>
</div>
</div>
<div class="pagefooter">
This page was last edited on Tue, 12 Sep 2023 19:20:08 +0930
|
<a href="https://en.wikipedia.org/wiki/Markdown" target="_blank" rel="nofollow">Markdown</a>
processed with
<a href="https://pandoc.org/MANUAL.html#pandocs-markdown" target="_blank" rel="nofollow">pandoc 3.1.12.1</a>
</div>
</div>
</div>
</body>
</html>