Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ways to trap function key
#5
(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!

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?
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.

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
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
Ways to trap function key - by eoredson - 01-20-2024, 06:55 AM
RE: Ways to trap function key - by PhilOfPerth - 01-20-2024, 10:00 AM
RE: Ways to trap function key - by SMcNeill - 01-20-2024, 12:28 PM
RE: Ways to trap function key - by bplus - 01-20-2024, 02:01 PM
RE: Ways to trap function key - by TerryRitchie - 01-20-2024, 02:26 PM
RE: Ways to trap function key - by bplus - 01-20-2024, 03:46 PM
RE: Ways to trap function key - by SMcNeill - 01-20-2024, 06:25 PM



Users browsing this thread: 2 Guest(s)