Three questions about keyboard-input in MSX-BASIC

Страница 2/2
1 |

By NYYRIKKI

Enlighted (6016)

Аватар пользователя NYYRIKKI

13-07-2011, 23:04

Result: DEFUSR=&H156 will not help, as each function key acts like multiple "keys" pressed at the same time, like if you press F1, you get letters c, o, l, o and r, that is five key presses indeed. That means, if you have several text pages (like story of a game or game instructions) and each text screen ends with "Press any key" and you use A$=INKEY$ and user presses function key, user will see several text screens quickly disappearing as soon as they get drawn.

Wrong, they are not "pressed at the same time" they are inserted to buffer one after each other, so you need to execute USR after each screen draw. This is not any kind of permanent solution. You need to execute USR always when you want buffer to be erased.

Though, by doing so, there is one bad thing, you will delete all those handy quick key words, like LIST and RUN+CHR$(13). Was there some POKE which reseted function keys back to normal? I think I have seen such thing mentioned here ages ago. Not 100% sure though.

No, but you can restore original values with DEFUSR=&H3E:A=USR(0)


How can you disable function keys?

fori=1to10:key(i)on:next

And how you can get them alive again?

fori=1to10:key(i)off:next

By MäSäXi

Paragon (1884)

Аватар пользователя MäSäXi

14-07-2011, 10:25

Result: DEFUSR=&H156 will not help, as each function key acts like multiple "keys" pressed at the same time, like if you press F1, you get letters c, o, l, o and r, that is five key presses indeed. That means, if you have several text pages (like story of a game or game instructions) and each text screen ends with "Press any key" and you use A$=INKEY$ and user presses function key, user will see several text screens quickly disappearing as soon as they get drawn.

Wrong, they are not "pressed at the same time" they are inserted to buffer one after each other, so you need to execute USR after each screen draw. This is not any kind of permanent solution. You need to execute USR always when you want buffer to be erased.

Yes, but my problem is, that I already used that DEFUSR=&H156 at the beginning of each line which contained A$=INKEY$ and at ONKEYGOSUB destination lines too, and that doesn´t help for function keys, function keys still makes program jump through several screens, as A$=INKEY$ treats function keys as multiple keypresses in buffer. But that FOR I=1 TO 10 : KEY I,"" : NEXT makes them behave. Smile Wink


No, but you can restore original values with DEFUSR=&H3E:A=USR(0)

Sehän se oli! Kiitos! Smile

(That was it! Thank you!Smile)


How can you disable function keys?

fori=1to10:key(i)on:next

And how you can get them alive again?

fori=1to10:key(i)off:next

No, I meant if there is some DEFUSR or POKE which disables them to solve my "jumps through several screens" problem. Smile But that FOR I=1 TO 10 : KEY I,"" : NEXT is fine for my purposes too. Smile

By NYYRIKKI

Enlighted (6016)

Аватар пользователя NYYRIKKI

14-07-2011, 10:44

Yes, but my problem is, that I already used that DEFUSR=&H156 at the beginning of each line which contained A$=INKEY$ and at ONKEYGOSUB destination lines too, and that doesn´t help for function keys, function keys still makes program jump through several screens, as A$=INKEY$ treats function keys as multiple keypresses in buffer.

You need to put DEFUSR=&H156 only at the beginning of program, but you should use A=USR(0) before each A$=INKEY$

This works, trust me... I know.
Try for example:
10 defusr=&h156:A=usr(0):fori=-1to0:a$=inkey$:i=(A$="" ):next:?a$:goto10


How can you disable function keys?

fori=1to10:key(i)on:next

And how you can get them alive again?

fori=1to10:key(i)off:next

No, I meant if there is some DEFUSR or POKE which disables them to solve my "jumps through several screens" problem. Smile But that FOR I=1 TO 10 : KEY I,"" : NEXT is fine for my purposes too. Smile

That is exactly the problem that these lines solve. No need to define keys empty. (No even need to define ON KEY GOSUB)

Страница 2/2
1 |