![]() |
Ways to trap function key - Printable Version +- QB64 Phoenix Edition (https://qb64phoenix.com/forum) +-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1) +--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3) +---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10) +---- Thread: Ways to trap function key (/showthread.php?tid=2394) |
Ways to trap function key - eoredson - 01-20-2024 This is not a bug report but I was about to declare an error. This code contains 2 ways to trap the F1 key: The difference is between soft key and scan key when key is set (has nothing to do with Key On or Key Off).. Code: (Select All) ' Ways to trap function keys. RE: Ways to trap function key - PhilOfPerth - 01-20-2024 Maybe I'm missing the point here, but I find it easiest to use the _keyhit funcion, which returns the value 15104 for example, for F1 RE: Ways to trap function key - SMcNeill - 01-20-2024 No worries Phil; I missed whatever point there was as well and thought the same as you. _KeyHit is your friend! RE: Ways to trap function key - bplus - 01-20-2024 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? RE: Ways to trap function key - TerryRitchie - 01-20-2024 (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. 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 RE: Ways to trap function key - bplus - 01-20-2024 cool, thanks terry (my left shift key is worn out0 damn! Probably got some food stuck under it ;-)) I must of known this when I was using gw back in the late 80's early 90's. Must be the siren call of _KeyHit that made me forget ![]() RE: Ways to trap function key - SMcNeill - 01-20-2024 Don't forget _DEVICES and INP, and PEEK/POKE methods, as well as various DECLARE LIBRARY code and $INCLUDE libraries... Wait... Why is it any harder to read function keys than it is anything else, anyway? It doesn't seem too limited to me. |