如何在自定义 TI 程序中使用箭头键
我已经研究了尽可能多的函数,但仍然找不到一个可以让您拦截 TI 箭头键点击的函数。
I have looked at as many functions as I can and I still can't find one that lets you intercept the click of a TI arrow key click.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对于使用“Prog”按钮运行的基本程序,您需要调用
getKey
,它返回最后按下的按钮的键代码。箭头按钮映射到代码24
、25
、26
和34
。更多信息请访问TI-Basic 开发人员,在“读取按键”标题下方。
For Basic programs, which are run with the "Prog" button, you'll need to call
getKey
, which returns a key code for the last button pressed. The arrow buttons are mapped to codes24
,25
,26
, and34
.More information is available at TI-Basic Developer, underneath the heading "Reading Keypresses".
我知道这是一个老问题,但我认为这一点可能仍然相关。
如果您使用按键输入来移动字符或以某种方式移动值,那么最好避免使用
if-then-else
语句。最快的方法通常是这样做:
可以进一步压缩为:
我们不通过
if
语句处理逻辑,而是利用(A=24)
有一个“布尔”值(0 或 1)。所以如果是某个值我们就加或者减1。设置限制也相当容易:
因此,如果
(X<20)
它将乘以 1,但当 X>=20 时,(X<20)
将乘以 0 ,否认罪名。我使用另一种技术来帮助在某些程序中选择值:向左键和向右键以与向上键和向下键不同的值递增和递减变量。然而,它需要更多的逻辑。
在这种情况下,左右箭头以十为单位,向上和向下以个为单位。使用
(X+10<=100)
代替(X<100)
,因为如果X=99
则后者为 true,因此 X最多可以达到 109。前者确保添加 10 不会超过限制。I know this is an old question, but I think this point might still be relevant.
If you are using the key input to move a character, or shift a value somehow, you are almost always better off avoiding
if-then-else
statements.The fastest method is usually to do something like this:
which can be further condensed to:
Instead of dealing with the logic through the
if
statements, we utilize the fact that the(A=24)
has a 'boolean' (0 or 1) value. So we add or subtract 1 if it is a certain value.Setting limits is also fairly easy:
So if
(X<20)
it will multiply by 1, but when X>=20,(X<20)
will multiply by 0, negating the incriment.I use another technique to help with selecting values in some of my programs: The left and right keys increment and decrement a variable by a different value than the up and down keys do. However, it requires some more logic.
In this case, the left and right arrows go by tens, and the up and down go by ones.
(X+10<=100)
is used instead of(X<100)
because the latter will be true ifX=99
so X can go up to 109. The former makes sure that adding ten will not exceed the limit.您应该能够使用 getkey 命令来完成此操作。
然后你就可以在整个程序中调用变量A了。
每个键都有一个通过 getkey 命令调用的编号。
所以你可以使用该变量,
(25 是向上箭头)
You should be able to do it with the getkey command.
Then you can recall the variable A throughout the program.
Each key has a number that is called through the getkey command.
So you can use that variable by,
(25 would be the up arrow)