如何在自定义 TI 程序中使用箭头键

发布于 2024-11-27 15:29:00 字数 48 浏览 2 评论 0原文

我已经研究了尽可能多的函数,但仍然找不到一个可以让您拦截 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

洛阳烟雨空心柳 2024-12-04 15:29:00

对于使用“Prog”按钮运行的基本程序,您需要调用 getKey,它返回最后按下的按钮的键代码。箭头按钮映射到代码 24252634

更多信息请访问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 codes 24, 25, 26, and 34.

More information is available at TI-Basic Developer, underneath the heading "Reading Keypresses".

背叛残局 2024-12-04 15:29:00

我知道这是一个老问题,但我认为这一点可能仍然相关。

如果您使用按键输入来移动字符或以某种方式移动值,那么最好避免使用 if-then-else 语句。

最快的方法通常是这样做:

:getkey -> A
:X+(A=24) -> X
:X-(A=26) -> X
:Y+(A=25) -> Y
:Y-(A=34) -> Y

可以进一步压缩为:

:getkey -> A
:X+(A=24)-(A=26) -> X
:Y+(A=25)-(A=34) -> Y

我们不通过 if 语句处理逻辑,而是利用 (A=24) 有一个“布尔”值(0 或 1)。所以如果是某个值我们就加或者减1。

设置限制也相当容易:

:getkey -> A
:X+(A=26)(X<=20)-(A=24)(X>0) -> X
:Y+(A=25)(Y<=15)-(A=34)(Y>=3) -> Y

因此,如果 (X<20) 它将乘以 1,但当 X>=20 时,(X<20) 将乘以 0 ,否认罪名。

我使用另一种技术来帮助在某些程序中选择值:向左键和向右键以与向上键和向下键不同的值递增和递减变量。然而,它需要更多的逻辑。

:getkey -> A
:X+10(A=26)(X+10<=100)-10(A=24)(X-10>=0) -> X
:Y+(A=25)(Y<15)-(A=34)(Y>3) -> B

在这种情况下,左右箭头以十为单位,向上和向下以个为单位。使用 (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:

:getkey -> A
:X+(A=24) -> X
:X-(A=26) -> X
:Y+(A=25) -> Y
:Y-(A=34) -> Y

which can be further condensed to:

:getkey -> A
:X+(A=24)-(A=26) -> X
:Y+(A=25)-(A=34) -> Y

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:

:getkey -> A
:X+(A=26)(X<=20)-(A=24)(X>0) -> X
:Y+(A=25)(Y<=15)-(A=34)(Y>=3) -> Y

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.

:getkey -> A
:X+10(A=26)(X+10<=100)-10(A=24)(X-10>=0) -> X
:Y+(A=25)(Y<15)-(A=34)(Y>3) -> B

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 if X=99 so X can go up to 109. The former makes sure that adding ten will not exceed the limit.

羞稚 2024-12-04 15:29:00

您应该能够使用 getkey 命令来完成此操作。

getkey (Store as) (Variable) A
while A=0
getkey (Store as) A

然后你就可以在整个程序中调用变量A了。
每个键都有一个通过 getkey 命令调用的编号。
所以你可以使用该变量,

If A = 25
...
If A != 25
...

(25 是向上箭头)

You should be able to do it with the getkey command.

getkey (Store as) (Variable) A
while A=0
getkey (Store as) A

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,

If A = 25
...
If A != 25
...

(25 would be the up arrow)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文