01-20-2024, 02:26 PM
(This post was last modified: 01-20-2024, 02:34 PM by TerryRitchie.)
(01-20-2024, 02:01 PM)bplus Wrote: Don't think I ever used the Key method in Eric's first example. So it was news to me no matter long it's been around. Thanks Eric!This goes all the way back to GWBasic. When you start GWBasic you'll see a row of text at the bottom of the screen. Each word equates to an F key. This can be turned on and off using KEY ON/OFF. You as the programmer could also set these to whatever you liked as you have discovered.
So that makes 4 ways to trap a key:
1. Inkey$
2. KeyHit
3. Keydown
4. Key
SmallBASIC had a way to associate a Key to a subroutine so that routine would execute when the Key was pressed, maybe ON KEY for us?
Just looked it up: Yes! On Key(1) would trap the F1 key and send you to a GoSub or Sub you setup on same command. Numbers 1-10 dedicated to Function keys then 11-14? the arrow keys, this old stuff probably came with QB4.5?
That's why in many GWBasic programs the first line usually read:
KEY OFF: CLS
Here's a site with some info:
http://www.antonis.de/qbebooks/gwbasman/key.html