Author Topic: Keyhit codes 173+  (Read 3436 times)

0 Members and 1 Guest are viewing this topic.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Keyhit codes 173+
« on: November 24, 2020, 10:01:05 am »
Since when did QB64 start reading extra keys on the keyboard and mapping them to the extended ASCII code set?

Mute is -173.
Volume Down is -174.
Volume Up is -175.
Fast Forward is -176.
Rewind is -177.
Stop is -178.
Play/Pause is -179.

NOTE:  QB64 doesn't read the key down values for these keys; just the key up values.  There's no corresponding +174 for when the volume down button is pressed; just the -174 for when it's released.

Am I the only one who gets these results?  Can anyone else with a multimedia keyboard test these?  Simple test code is below:

Code: QB64: [Select]
  1.     _LIMIT 30
  2.     k = _KEYHIT
  3.     IF k <> 0 THEN PRINT k
  4. LOOP UNTIL k = 27

Never before have I ever had to watch for my volume control interacting with a program I'm running.  Did we change something in the way we handle keyboard events in QB64?  Did windows decide to remap things sometime recently, in one of their latest patches?  Or am I just crazy and this is something we've always had that I've simply never noticed before?
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline doppler

  • Forum Regular
  • Posts: 241
    • View Profile
Re: Keyhit codes 173+
« Reply #1 on: November 24, 2020, 02:37:09 pm »
I think it's always been there.  I was using function keys F13 to F16 as extensions to the key board (aka hidden keys).  Autohotkey would send the keys out and my QB64 program would respond in kind.  Microsoft has a full list of key hit codes.

This might help: https://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Keyhit codes 173+
« Reply #2 on: November 24, 2020, 03:16:21 pm »
Hi Steve,

There are several keys that did not respond... Play; Speaker volume (up and down); Speaker mute; Print Screen; Screen Lock; Pause; 'window' and Calculator.
All other keys registered 'Pressed' and 'Released'. Hope this helps.

J
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Keyhit codes 173+
« Reply #3 on: November 24, 2020, 04:05:35 pm »
I confirm all those keys except Stop, I've been robbed (again) on my HP Laptop keyboard!

Oh happy day, I finally found the ins key (in fine print over prt sc key), now if I can just remember next time I'm editing...

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Keyhit codes 173+
« Reply #4 on: November 24, 2020, 08:18:49 pm »
@johnno56, @bplus Since there was keys which _KEYHIT couldn't read for you guys, and since you're both users of Windows, test the following code out and see how it reads things for you:

Code: QB64: [Select]
  1. DECLARE LIBRARY 'function is already used by QB64 so "User32" is not required
  2.     FUNCTION GetKeyState% (BYVAL vkey AS LONG)
  3.     FUNCTION GetAsyncKeyState% (BYVAL vkey AS LONG)
  4.  
  5. TYPE KeyboardInfo_Type
  6.     Index AS LONG
  7.     ASCII AS LONG
  8.     Ctrl AS LONG
  9.     Shift AS LONG
  10.     Alt AS LONG
  11.     AltGr AS LONG
  12.     Repeat AS _FLOAT
  13.     LastHit AS _FLOAT
  14.     Down AS LONG
  15.     AltShift AS LONG
  16.     AltCtrl AS LONG
  17.     AltAltGr AS LONG
  18.     CtrlShift AS LONG
  19.     CtrlAlt AS LONG
  20.     CtrlAltGr AS LONG
  21.     ShiftAltGr AS LONG
  22.     CtrlAltShift AS LONG
  23.  
  24. DIM SHARED Keys(254) AS KeyboardInfo_Type
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.     _LIMIT 120
  32.     k = KeyHit
  33.     IF k <> 0 THEN PRINT k
  34. LOOP UNTIL k = 27
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. SUB SetAltGr (Key1 AS INTEGER, Key2 AS INTEGER)
  49.     AltGr(0) = Key1 'any key from our index (0 says no key)
  50.     AltGr(1) = Key2 'PLUS any other key from our index (0 says no additional key)
  51.     'Using this, we can set AltGr to become several things.
  52.     'AltGr(0) = 165, AltGr(1) = 0 -- This would say we're using the RIGHT Alt key (alone) to simulate the AltGr key.  (Windows Onscreen Keyboard does this.)
  53.     'AltGr(0) = 17, AltGr(1) = 18 -- This would use any CTRL-ALT combo to simulate a AltGr keypress.
  54.     'Some useful values are listed for quick reference below
  55.     '0 = NoKey
  56.     '17 = ANY Ctrl
  57.     '18 = ANY Alt
  58.     '162 = Left Control
  59.     '163 = Right Control
  60.     '164 = Left Alt
  61.     '165 = Right Alt
  62.  
  63.     'Default is for AltGr(0) = 165, AltGr(1) = 0, which uses Right-Alt alone as the AltGr key.
  64.     'Feel free to customize the setting to your personal preference/need.
  65.  
  66. SUB KeyClear
  67.     _DELAY .05 'give time for a keyup event to log itself so we can clear it
  68.     DO: k = KeyHit: LOOP UNTIL k = 0
  69.  
  70. FUNCTION KeyHit&
  71.     STATIC ReturnCount AS INTEGER
  72.     STATIC ReturnValues(30) AS LONG
  73.     SHARED AltGr, Alt, Shift, Ctrl
  74.     IF Keys(1).Index = 0 THEN Init_KeyCodes "US" 'if someone forgets to put the init routine in their code, be certain to initialize the codes before attempting to use them.
  75.  
  76.  
  77.     IF ReturnCount > 0 THEN 'If we generated a cue of values last pass, clear those up first, before getting new values.
  78.         'The only time we really see this is when we hit a shift, ctrl, alt key, usually.
  79.         KeyHit = ReturnValues(1)
  80.         FOR i = 1 TO ReturnCount - 1
  81.             ReturnValues(i) = ReturnValues(i + 1)
  82.         NEXT
  83.         ReturnCount = ReturnCount - 1
  84.         EXIT FUNCTION
  85.     END IF
  86.  
  87.     IF Keys(16).Down THEN Shift = -1 ELSE Shift = 0
  88.     IF Keys(17).Down THEN Ctrl = -1 ELSE Ctrl = 0
  89.     IF Keys(18).Down THEN Alt = -1 ELSE Alt = 0
  90.     IF AltGr(0) <> 0 AND AltGr(1) <> 0 THEN
  91.         IF Keys(AltGr(0)).Down AND Keys(AltGr(1)).Down THEN AltGr = -1 ELSE AltGr = 0
  92.     ELSEIF AltGr(1) <> 0 THEN
  93.         IF Keys(AltGr(1)).Down THEN AltGr = -1 ELSE AltGr = 0
  94.     ELSEIF AltGr(0) <> 0 THEN
  95.         IF Keys(AltGr(0)).Down THEN AltGr = -1 ELSE AltGr = 0
  96.     ELSE
  97.         AltGr = 0
  98.     END IF
  99.  
  100.     'until Ctrl or Alt status, if the key down was used to help generate AltGr as a modifier key
  101.     IF AltGr THEN
  102.         IF (AltGr(0) = 18 OR AltGr(1) = 18) THEN Alt = 0 'if we use both ALT keys to represent part of AltGr, when AltGr is active, Alt isn't.
  103.         IF (AltGr(0) = 164 OR AltGr(1) = 164) AND Keys(165).Down = 0 THEN Alt = 0 'if we use Left ALT keys to represent part of AltGr, when AltGr is active, Left Alt isn't.
  104.         IF (AltGr(0) = 165 OR AltGr(1) = 165) AND Keys(164).Down = 0 THEN Alt = 0 'if we use Right ALT keys to represent part of AltGr, when AltGr is active, Right Alt isn't.
  105.         IF (AltGr(0) = 17 OR AltGr(1) = 17) THEN Ctrl = 0 'if we use both CTRL keys to represent part of AltGr, when AltGr is active, Ctrl isn't.
  106.         IF (AltGr(0) = 162 OR AltGr(1) = 162) AND Keys(163).Down = 0 THEN Ctrl = 0 'if we use Left CTRL keys to represent part of AltGr, when AltGr is active, Left Ctrl isn't.
  107.         IF (AltGr(0) = 163 OR AltGr(1) = 163) AND Keys(162).Down = 0 THEN Ctrl = 0 'if we use Right CTRL keys to represent part of AltGr, when AltGr is active, Right Ctrl isn't.
  108.     END IF
  109.  
  110.     IF Alt AND Shift THEN AltShift = -1 ELSE AltShift = 0
  111.     IF Alt AND Ctrl THEN AltCtrl = -1 ELSE AltCtrl = 0
  112.     IF Alt AND AltAltGR THEN AltAltGR = -1 ELSE AltAltGR = 0
  113.     IF Ctrl AND Shift THEN CtrlShift = -1 ELSE CtrlShift = 0
  114.     IF Shift AND AltGr THEN ShiftAltGr = -1 ELSE ShiftAltGr = 0
  115.     IF Ctrl AND Alt AND Shift THEN CtrlAltShift = -1 ELSE CtrlAltShift = 0
  116.  
  117.         FOR i = 1 TO 254
  118.  
  119.             r = GetKeyState(Keys(i).Index) AND &H8000
  120.  
  121.             IF r THEN 'the key is down
  122.  
  123.  
  124.                 IF Keys(i).LastHit THEN
  125.                     IF ExtendedTimer > Keys(i).LastHit THEN
  126.                         ReturnCount = ReturnCount + 1 'add one to the return buffer
  127.                         ReturnValues(ReturnCount) = Keys(i).Down 'and put the existing value back in the buffer, as a key repeat
  128.                     END IF
  129.                 ELSE
  130.  
  131.                     IF Keys(i).Down = 0 THEN 'the key was up on the last pass.
  132.                         IF CtrlAltShift <> 0 AND Keys(i).CtrlAltShift <> 0 THEN 'return the CtrlAltShift value
  133.                             Keys(i).Down = Keys(i).CtrlAltShift
  134.                         ELSEIF AltAltGR <> 0 AND Keys(i).AltAltGr <> 0 THEN 'return the AltAltGr value
  135.                             Keys(i).Down = Keys(i).AltAltGr
  136.                         ELSEIF CtrlAltGr& <> 0 AND Keys(i).CtrlAltGr& <> 0 THEN 'return the CtrlAltGr& value
  137.                             Keys(i).Down = Keys(i).CtrlAltGr&
  138.                         ELSEIF ShiftAltGr <> 0 AND Keys(i).ShiftAltGr <> 0 THEN 'return the ShiftAltGr value
  139.                             Keys(i).Down = Keys(i).ShiftAltGr
  140.                         ELSEIF CtrlShift <> 0 AND Keys(i).CtrlShift <> 0 THEN 'return the CtrlShift value
  141.                             Keys(i).Down = Keys(i).CtrlShift
  142.                         ELSEIF AltCtrl <> 0 AND Keys(i).AltCtrl <> 0 THEN 'return the AltCtrl value
  143.                             Keys(i).Down = Keys(i).AltCtrl
  144.                         ELSEIF AltShift <> 0 AND Keys(i).AltShift <> 0 THEN 'return the AltShift value
  145.                             Keys(i).Down = Keys(i).AltShift
  146.                         ELSEIF AltGr <> 0 AND Keys(i).AltGr <> 0 THEN 'return the altgr value
  147.                             Keys(i).Down = Keys(i).AltGr
  148.                         ELSEIF Shift <> 0 AND Keys(i).Shift <> 0 THEN 'return the shift value
  149.                             Keys(i).Down = Keys(i).Shift
  150.                             IF _CAPSLOCK = 0 THEN 'caps lock basically reverses the behavior of the shift key with the letters A-Z and a-z
  151.                                 SELECT CASE i
  152.                                     CASE 65 TO 90: Keys(i).Down = Keys(i).ASCII
  153.                                 END SELECT
  154.                             END IF
  155.                         ELSEIF (Ctrl <> 0) AND (Keys(i).Ctrl <> 0) THEN 'return the ctrl value
  156.                             Keys(i).Down = Keys(i).Ctrl
  157.                         ELSEIF Alt <> 0 AND Keys(i).Alt <> 0 THEN 'return the alt value
  158.                             Keys(i).Down = Keys(i).Alt
  159.                         ELSE 'all that's left is to return the ASCII value
  160.                             Keys(i).Down = Keys(i).ASCII
  161.                             IF _CAPSLOCK = 0 THEN 'caps lock basically reverses the behavior of the shift key with the letters A-Z and a-z
  162.                                 SELECT CASE i
  163.                                     CASE 65 TO 90: Keys(i).Down = Keys(i).Shift
  164.                                 END SELECT
  165.                             END IF
  166.                         END IF
  167.                         ReturnCount = ReturnCount + 1 'add one to the return buffer
  168.                         ReturnValues(ReturnCount) = Keys(i).Down 'and store the value in the buffer
  169.  
  170.                         IF Keys(i).Repeat = -1 THEN 'keys that are set to a -1 on repeat simply toggle state as on, or off.
  171.                             Keys(i).LastHit = 1E+1000 'such as SHIFT, CTRL, ALT...
  172.                         ELSE
  173.                             Keys(i).LastHit = ExtendedTimer + Keys(i).Repeat 'and record when we hit it for repeat purposes
  174.                         END IF
  175.                     END IF
  176.                 END IF
  177.             ELSE
  178.                 IF Keys(i).Down THEN 'the key was down on the last pass
  179.                     ReturnCount = ReturnCount + 1
  180.                     ReturnValues(ReturnCount) = -Keys(i).Down 'mark it as being up on this one
  181.                 END IF
  182.                 Keys(i).Down = 0 'and set it back down for future passes
  183.                 Keys(i).LastHit = 0 'once again, set it as being ready to be hit again
  184.             END IF
  185.         NEXT
  186.  
  187.         IF ReturnCount > 0 THEN 'If we generated a cue of values last pass, clear those up first, before getting new values.
  188.             'The only time we really see this is when we hit a shift, ctrl, alt key, usually.
  189.             KeyHit = ReturnValues(1)
  190.             FOR i = 1 TO ReturnCount - 1
  191.                 ReturnValues(i) = ReturnValues(i + 1)
  192.             NEXT
  193.             ReturnCount = ReturnCount - 1
  194.             EXIT FUNCTION
  195.         END IF
  196.  
  197.     END IF 'End of IF _WINDOWHASFOCUS
  198.  
  199.  
  200.  
  201.  
  202. SUB Remap_KeyCode (Which AS LONG, ASCII AS LONG, Ctrl AS LONG, Shift AS LONG, Alt AS LONG, AltGr AS LONG, Repeat AS _FLOAT)
  203.     DIM i AS LONG
  204.     i = Which
  205.     Keys(i).Index = i
  206.     Keys(i).ASCII = ASCII
  207.     Keys(i).Ctrl = Ctrl
  208.     Keys(i).Shift = Shift
  209.     Keys(i).Alt = Alt
  210.     Keys(i).AltGr = AltGr
  211.     Keys(i).Repeat = Repeat
  212.     Keys(i).LastHit = 0
  213.     Keys(i).Down = 0
  214.  
  215. SUB Remap_Extended_KeyCode (Which&, AltShift&, AltCtrl&, AltAltGr&, _
  216.          CtrlShift&, CtrlAltGr&, ShiftAltGr&, CtrlAltShift&)
  217.     Keys(Which&).AltShift = AltShift&
  218.     Keys(Which&).AltCtrl = AltCtrl&
  219.     Keys(Which&).AltAltGr = AltAltGr&
  220.     Keys(Which&).CtrlShift = CtrlShift&
  221.     Keys(Which&).CtrlAltGr = CtrlAltGr&
  222.     Keys(Which&).ShiftAltGr = ShiftAltGr&
  223.     Keys(Which&).CtrlAltShift = CtrlAltShift&
  224.  
  225. FUNCTION KeyDown& (Code AS LONG)
  226.     IF Code <= 0 THEN EXIT FUNCTION
  227.     FOR i = 1 TO 254
  228.         IF GetAsyncKeyState(i) THEN 'first check for actual physical keys down
  229.             IF Keys(i).ASCII = Code THEN KeyDown = -1: EXIT FUNCTION 'then check to see if the code matches anything we've mapped it to.
  230.             IF Keys(i).Shift = Code THEN KeyDown = -1: EXIT FUNCTION
  231.             IF Keys(i).Alt = Code THEN KeyDown = -1: EXIT FUNCTION
  232.             IF Keys(i).AltGr = Code THEN KeyDown = -1: EXIT FUNCTION
  233.             IF Keys(i).AltShift = Code THEN KeyDown = -1: EXIT FUNCTION
  234.             IF Keys(i).AltCtrl = Code THEN KeyDown = -1: EXIT FUNCTION
  235.             IF Keys(i).AltAltGr = Code THEN KeyDown = -1: EXIT FUNCTION
  236.             IF Keys(i).CtrlShift = Code THEN KeyDown = -1: EXIT FUNCTION
  237.             IF Keys(i).CtrlAltGr = Code THEN KeyDown = -1: EXIT FUNCTION
  238.             IF Keys(i).ShiftAltGr = Code THEN KeyDown = -1: EXIT FUNCTION
  239.             IF Keys(i).CtrlAltShift = Code THEN KeyDown = -1: EXIT FUNCTION
  240.         END IF
  241.     NEXT
  242.     KeyDown& = 0
  243.  
  244. SUB Init_KeyCodes (Language AS STRING)
  245.     RESTORE default_keyboard_data
  246.     FOR i = 1 TO 254
  247.         READ Keys(i).Index, Keys(i).ASCII, Keys(i).Ctrl, Keys(i).Shift, Keys(i).Alt, Keys(i).AltGr, Keys(i).Repeat
  248.         Keys(i).LastHit = 0: Keys(i).Down = 0
  249.     NEXT
  250.  
  251.     default_keyboard_data:
  252.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  253.     DATA 1,900001,0,0,0,0,0.2: 'Left Mouse Button
  254.     DATA 2,900002,0,0,0,0,0.2: 'Right Mouse Button
  255.     DATA 3,900003,0,0,0,0,0.2: 'VK_Cancel
  256.     DATA 4,900004,0,0,0,0,0.2: 'Middle Mouse Button
  257.     DATA 5,900005,0,0,0,0,0.2: 'Mouse Button 4
  258.     DATA 6,900006,0,0,0,0,0.2: 'Mouse Button 5
  259.     DATA 7,900007,0,0,0,0,0.2: 'Undefined
  260.     DATA 8,8,0,0,0,0,0.2: 'Backspace
  261.     DATA 9,9,0,0,0,0,0.2: 'Tab
  262.     DATA 10,900010,0,0,0,0,0.2: 'Reserved
  263.     DATA 11,900011,0,0,0,0,0.2: 'Reserved
  264.     DATA 12,19456,0,0,0,0,0.2: 'Clear
  265.     DATA 13,13,0,0,0,0,0.2: 'Enter
  266.     DATA 14,900014,0,0,0,0,0.2: 'Undefined
  267.     DATA 15,900015,0,0,0,0,0.2: 'Undefined
  268.     DATA 16,100016,0,0,0,0,-1: 'Shift (Notice I set it to simple toddle and report UP/DOWN results for us)
  269.     DATA 17,100017,0,0,0,0,-1: 'Ctrl   (Same)
  270.     DATA 18,100018,0,0,0,0,-1: 'Alt     (Same)
  271.     DATA 19,100019,0,0,0,0,0.2: 'Pause
  272.     DATA 20,100301,0,0,0,0,-1: 'Caps Lock
  273.     DATA 21,900021,0,0,0,0,0.2: 'VK_Hangul
  274.     DATA 22,900022,0,0,0,0,0.2: 'Undefined
  275.     DATA 23,900023,0,0,0,0,0.2: 'VK_Junja
  276.     DATA 24,900024,0,0,0,0,0.2: 'VK_Final
  277.     DATA 25,900025,0,0,0,0,0.2: 'VK_Hanga//VK_Kanji
  278.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  279.     DATA 26,900026,0,0,0,0,0.2: 'Undefined
  280.     DATA 27,27,0,0,0,0,0.2: 'ESC
  281.     DATA 28,900028,0,0,0,0,0.2: 'VK_Convert
  282.     DATA 29,900029,0,0,0,0,0.2: 'VK_NonConvert
  283.     DATA 30,900030,0,0,0,0,0.2: 'VK_Accept
  284.     DATA 31,900031,0,0,0,0,0.2: 'VK_ModeChange
  285.     DATA 32,32,0,0,0,0,0.2: 'VK_Space
  286.     DATA 33,18688,0,0,0,0,0.2: 'Page Up
  287.     DATA 34,20736,0,0,0,0,0.2: 'Page Down
  288.     DATA 35,20224,0,0,0,0,0.2: 'End
  289.     DATA 36,18176,0,0,0,0,0.2: 'Home
  290.     DATA 37,19200,0,0,0,0,0.2: 'Left Arrow
  291.     DATA 38,18432,0,0,0,0,0.2: 'Up Arrow
  292.     DATA 39,19712,0,0,0,0,0.2: 'Right Arrow
  293.     DATA 40,20480,0,0,0,0,0.2: 'Down Arrow
  294.     DATA 41,900041,0,0,0,0,-1: 'VK_SELECT
  295.     DATA 42,900042,0,0,0,0,-1: 'CK_PRINT
  296.     DATA 43,900043,0,0,0,0,-1: 'VK_EXECUTE
  297.     DATA 44,900044,0,0,0,0,-1: 'VK_SNAPSHOT
  298.     DATA 45,20992,0,0,0,0,0.2: 'INS
  299.     DATA 46,21248,0,0,0,0,0.2: 'DEL
  300.     DATA 47,900047,0,0,0,0,0.2: 'VK_HELP
  301.     DATA 48,48,0,41,0,0,0.2: '0
  302.     DATA 49,49,0,33,0,0,0.2: '1
  303.     DATA 50,50,0,64,0,0,0.2: '2
  304.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  305.     DATA 51,51,0,35,0,0,0.2: '3
  306.     DATA 52,52,0,36,0,0,0.2: '4
  307.     DATA 53,53,0,37,0,0,0.2: '5
  308.     DATA 54,54,0,94,0,0,0.2: '6
  309.     DATA 55,55,0,38,0,0,0.2: '7
  310.     DATA 56,56,0,42,0,0,0.2: '8
  311.     DATA 57,57,0,40,0,0,0.2: '9
  312.     DATA 58,900058,0,0,0,0,0.2: 'Undefined
  313.     DATA 59,900059,0,0,0,0,0.2: 'Undefined
  314.     DATA 60,900060,0,0,0,0,0.2: 'Undefined
  315.     DATA 61,900061,0,0,0,0,0.2: 'Undefined
  316.     DATA 62,900062,0,0,0,0,0.2: 'Undefined
  317.     DATA 63,900063,0,0,0,0,0.2: 'Undefined
  318.     DATA 64,900064,0,0,0,0,0.2: 'Undefined
  319.     DATA 65,65,0,97,0,0,0.2: 'a
  320.     DATA 66,66,0,98,0,0,0.2: 'b
  321.     DATA 67,67,0,99,0,0,0.2: 'c
  322.     DATA 68,68,0,100,0,0,0.2: 'd
  323.     DATA 69,69,0,101,0,0,0.2: 'e
  324.     DATA 70,70,0,102,0,0,0.2: 'f
  325.     DATA 71,71,0,103,0,0,0.2: 'g
  326.     DATA 72,72,0,104,0,0,0.2: 'h
  327.     DATA 73,73,0,105,0,0,0.2: 'i
  328.     DATA 74,74,0,106,0,0,0.2: 'j
  329.     DATA 75,75,0,107,0,0,0.2: 'k
  330.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  331.     DATA 76,76,0,108,0,0,0.2: 'l
  332.     DATA 77,77,0,109,0,0,0.2: 'm
  333.     DATA 78,78,0,110,0,0,0.2: 'n
  334.     DATA 79,79,0,111,0,0,0.2: 'o
  335.     DATA 80,80,0,112,0,0,0.2: 'p
  336.     DATA 81,81,0,113,0,0,0.2: 'q
  337.     DATA 82,82,0,114,0,0,0.2: 'r
  338.     DATA 83,83,0,115,0,0,0.2: 's
  339.     DATA 84,84,0,116,0,0,0.2: 't
  340.     DATA 85,85,0,117,0,0,0.2: 'u
  341.     DATA 86,86,0,118,0,0,0.2: 'v
  342.     DATA 87,87,0,119,0,0,0.2: 'w
  343.     DATA 88,88,0,120,0,0,0.2: 'x
  344.     DATA 89,89,0,121,0,0,0.2: 'y
  345.     DATA 90,90,0,122,0,0,0.2: 'z
  346.     DATA 91,100311,0,0,0,0,-1: 'Left WIN
  347.     DATA 92,100312,0,0,0,0,-1: 'Right WIN
  348.     DATA 93,100319,0,0,0,0,-1: 'Applications (Menu)
  349.     DATA 94,900094,0,0,0,0,0.2: 'Reserved
  350.     DATA 95,900095,0,0,0,0,0.2: 'VK_SLEEP
  351.     DATA 96,48,0,0,0,0,0.2: 'Numpad 0
  352.     DATA 97,49,0,0,0,0,0.2: 'Numpad 1
  353.     DATA 98,50,0,0,0,0,0.2: 'Numpad 2
  354.     DATA 99,51,0,0,0,0,0.2: 'Numpad 3
  355.     DATA 100,52,0,0,0,0,0.2: 'Numpad 4
  356.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  357.     DATA 101,53,0,0,0,0,0.2: 'Numpad 5
  358.     DATA 102,54,0,0,0,0,0.2: 'Numpad 6
  359.     DATA 103,55,0,0,0,0,0.2: 'Numpad 7
  360.     DATA 104,56,0,0,0,0,0.2: 'Numpad 8
  361.     DATA 105,57,0,0,0,0,0.2: 'Numpad 9
  362.     DATA 106,42,0,0,0,0,0.2: 'Numpad *
  363.     DATA 107,43,0,0,0,0,0.2: 'Numpad +
  364.     DATA 108,900108,0,0,0,0,0.2: 'VK_SEPARATOR
  365.     DATA 109,51,0,0,0,0,0.2: 'Numpad -
  366.     DATA 110,52,0,0,0,0,0.2: 'Numpad .
  367.     DATA 111,53,0,0,0,0,0.2: 'Numpad /
  368.     DATA 112,15104,0,0,0,0,0.2: 'F1
  369.     DATA 113,15360,0,0,0,0,0.2: 'F2
  370.     DATA 114,15616,0,0,0,0,0.2: 'F3
  371.     DATA 115,15872,0,0,0,0,0.2: 'F4
  372.     DATA 116,16128,0,0,0,0,0.2: 'F5            /
  373.     DATA 117,16384,0,0,0,0,0.2: 'F6
  374.     DATA 118,16640,0,0,0,0,0.2: 'F7
  375.     DATA 119,16896,0,0,0,0,0.2: 'F8
  376.     DATA 120,17152,0,0,0,0,0.2: 'F9
  377.     DATA 121,17408,0,0,0,0,0.2: 'F10
  378.     DATA 122,34048,0,0,0,0,0.2: 'F11
  379.     DATA 123,34304,0,0,0,0,0.2: 'F12
  380.     DATA 124,900124,0,0,0,0,0.2: 'F13
  381.     DATA 125,900125,0,0,0,0,0.2: 'F14
  382.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  383.     DATA 126,900126,0,0,0,0,0.2: 'F15
  384.     DATA 127,900127,0,0,0,0,0.2: 'F16
  385.     DATA 128,900128,0,0,0,0,0.2: 'F17
  386.     DATA 129,900129,0,0,0,0,0.2: 'F18
  387.     DATA 130,900130,0,0,0,0,0.2: 'F19
  388.     DATA 131,900131,0,0,0,0,0.2: 'F20
  389.     DATA 132,900132,0,0,0,0,0.2: 'F21
  390.     DATA 133,900133,0,0,0,0,0.2: 'F22
  391.     DATA 134,900134,0,0,0,0,0.2: 'F23
  392.     DATA 135,900135,0,0,0,0,0.2: 'F24
  393.     DATA 136,900136,0,0,0,0,0.2: 'Unassigned
  394.     DATA 137,900137,0,0,0,0,0.2: 'Unassigned
  395.     DATA 138,900138,0,0,0,0,0.2: 'Unassigned
  396.     DATA 139,900139,0,0,0,0,0.2: 'Unassigned
  397.     DATA 140,900140,0,0,0,0,0.2: 'Unassigned
  398.     DATA 141,900141,0,0,0,0,0.2: 'Unassigned
  399.     DATA 142,900142,0,0,0,0,0.2: 'Unassigned
  400.     DATA 143,900143,0,0,0,0,0.2: 'Unassigned
  401.     DATA 144,100300,0,0,0,0,-1: 'NUM LOCK
  402.     DATA 145,100302,0,0,0,0,-1: 'SCROLL LOCK
  403.     DATA 146,900146,0,0,0,0,0.2: 'OEM SPECIFIC
  404.     DATA 147,900147,0,0,0,0,0.2: 'OEM SPECIFIC
  405.     DATA 148,900148,0,0,0,0,0.2: 'OEM SPECIFIC
  406.     DATA 149,900149,0,0,0,0,0.2: 'OEM SPECIFIC
  407.     DATA 150,900150,0,0,0,0,0.2: 'OEM SPECIFIC
  408.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  409.     DATA 151,900151,0,0,0,0,0.2: 'Unassigned
  410.     DATA 152,900152,0,0,0,0,0.2: 'Unassigned
  411.     DATA 153,900153,0,0,0,0,0.2: 'Unassigned
  412.     DATA 154,900154,0,0,0,0,0.2: 'Unassigned
  413.     DATA 155,900155,0,0,0,0,0.2: 'Unassigned
  414.     DATA 156,900156,0,0,0,0,0.2: 'Unassigned
  415.     DATA 157,900157,0,0,0,0,0.2: 'Unassigned
  416.     DATA 158,900158,0,0,0,0,0.2: 'Unassigned
  417.     DATA 159,900159,0,0,0,0,0.2: 'Unassigned
  418.     DATA 160,100304,0,0,0,0,-1: 'Left Shift
  419.     DATA 161,100303,0,0,0,0,-1: 'Right Shift
  420.     DATA 162,100306,0,0,0,0,-1: 'Left Control
  421.     DATA 163,100305,0,0,0,0,-1: 'Right Control
  422.     DATA 164,100308,0,0,0,0,-1: 'Left Alt
  423.     DATA 165,100309,0,0,0,0,-1: 'Right Alt
  424.     DATA 166,900166,0,0,0,0,0.2: 'Browser back
  425.     DATA 167,900167,0,0,0,0,0.2: 'Browser forward
  426.     DATA 168,900168,0,0,0,0,0.2: 'Browser refresh
  427.     DATA 169,900169,0,0,0,0,0.2: 'Browser stop
  428.     DATA 170,900170,0,0,0,0,0.2: 'Browser search
  429.     DATA 171,900171,0,0,0,0,0.2: 'Browser favorites
  430.     DATA 172,900172,0,0,0,0,0.2: 'Browser home
  431.     DATA 173,900173,0,0,0,0,0.2: 'Mute
  432.     DATA 174,900174,0,0,0,0,0.2: 'Vol Down
  433.     DATA 175,900175,0,0,0,0,0.2: 'Vol Up
  434.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  435.     DATA 176,900176,0,0,0,0,0.2: 'Media Next
  436.     DATA 177,900177,0,0,0,0,0.2: 'Media prev
  437.     DATA 178,900178,0,0,0,0,0.2: 'Media stop
  438.     DATA 179,900179,0,0,0,0,0.2: 'Media Play/Pause
  439.     DATA 180,900180,0,0,0,0,0.2: 'Launch mail
  440.     DATA 181,900181,0,0,0,0,0.2: 'Launch media select
  441.     DATA 182,900182,0,0,0,0,0.2: 'Launch app1
  442.     DATA 183,900183,0,0,0,0,0.2: 'Launch app2
  443.     DATA 184,900184,0,0,0,0,0.2: 'Reserved
  444.     DATA 185,900185,0,0,0,0,0.2: 'Reserved
  445.     DATA 186,59,0,58,0,0,0.2: ';:
  446.     DATA 187,61,0,43,0,0,0.2: '=+
  447.     DATA 188,44,0,60,0,0,0.2: ',<
  448.     DATA 189,45,0,95,0,0,0.2: '-_
  449.     DATA 190,46,0,62,0,0,0.2: '.>
  450.     DATA 191,47,0,63,0,0,0.2: '/?
  451.     DATA 192,96,0,126,0,0,0.2: '`~
  452.     DATA 193,900193,0,0,0,0,0.2: 'Reserved
  453.     DATA 194,900194,0,0,0,0,0.2: 'Reserved
  454.     DATA 195,900195,0,0,0,0,0.2: 'Reserved
  455.     DATA 196,900196,0,0,0,0,0.2: 'Reserved
  456.     DATA 197,900197,0,0,0,0,0.2: 'Reserved
  457.     DATA 198,900198,0,0,0,0,0.2: 'Reserved
  458.     DATA 199,900199,0,0,0,0,0.2: 'Reserved
  459.     DATA 200,900200,0,0,0,0,0.2: 'Reserved
  460.     '   Index   Unmodified      Ctrl      Shift       Alt         AltGr     Repeat
  461.     DATA 201,900201,0,0,0,0,0.2: 'Reserved
  462.     DATA 202,900202,0,0,0,0,0.2: 'Reserved
  463.     DATA 203,900203,0,0,0,0,0.2: 'Reserved
  464.     DATA 204,900204,0,0,0,0,0.2: 'Reserved
  465.     DATA 205,900205,0,0,0,0,0.2: 'Reserved
  466.     DATA 206,900206,0,0,0,0,0.2: 'Reserved
  467.     DATA 207,900207,0,0,0,0,0.2: 'Reserved
  468.     DATA 208,900208,0,0,0,0,0.2: 'Reserved
  469.     DATA 209,900209,0,0,0,0,0.2: 'Reserved
  470.     DATA 210,900210,0,0,0,0,0.2: 'Reserved
  471.     DATA 211,900211,0,0,0,0,0.2: 'Reserved
  472.     DATA 212,900212,0,0,0,0,0.2: 'Reserved
  473.     DATA 213,900213,0,0,0,0,0.2: 'Reserved
  474.     DATA 214,900214,0,0,0,0,0.2: 'Reserved
  475.     DATA 215,900215,0,0,0,0,0.2: 'Reserved
  476.     DATA 216,900216,0,0,0,0,0.2: 'Unassigned
  477.     DATA 217,900217,0,0,0,0,0.2: 'Unassigned
  478.     DATA 218,900218,0,0,0,0,0.2: 'Unassigned
  479.     DATA 219,91,0,123,0,0,0.2: '[{
  480.     DATA 220,92,0,124,0,0,0.2: '\|
  481.     DATA 221,93,0,125,0,0,0.2: ']}
  482.     DATA 222,39,0,34,0,0,0.2: ''"
  483.     DATA 223,900223,0,0,0,0,0.2: 'OEM SPECIFIC
  484.     DATA 224,900224,0,0,0,0,0.2: 'Reserved
  485.     DATA 225,900225,0,0,0,0,0.2: 'OEM SPECIFIC d
  486.     DATA 226,900226,0,0,0,0,0.2: 'Either the Angle Bracket key,or Backslash on RT 102-key keyboard
  487.     DATA 227,900227,0,0,0,0,0.2: 'OEM SPECIFIC
  488.     DATA 228,900228,0,0,0,0,0.2: 'OEM SPECIFIC
  489.     DATA 229,900229,0,0,0,0,0.2: 'IME PROCESS key (whatever that is)
  490.     DATA 230,900230,0,0,0,0,0.2: 'OEM SPECIFIC
  491.     DATA 231,900231,0,0,0,0,0.2: 'Used to pass UNICODE characters (however that works)
  492.     DATA 232,900232,0,0,0,0,0.2: 'Unassigned
  493.     DATA 233,900233,0,0,0,0,0.2: 'OEM SPECIFIC
  494.     DATA 234,900234,0,0,0,0,0.2: 'OEM SPECIFIC
  495.     DATA 235,900235,0,0,0,0,0.2: 'OEM SPECIFIC
  496.     DATA 236,900236,0,0,0,0,0.2: 'OEM SPECIFIC
  497.     DATA 237,900237,0,0,0,0,0.2: 'OEM SPECIFIC
  498.     DATA 238,900238,0,0,0,0,0.2: 'OEM SPECIFIC
  499.     DATA 239,900239,0,0,0,0,0.2: 'OEM SPECIFIC
  500.     DATA 240,900240,0,0,0,0,0.2: 'OEM SPECIFIC
  501.     DATA 241,900241,0,0,0,0,0.2: 'OEM SPECIFIC
  502.     DATA 242,900242,0,0,0,0,0.2: 'OEM SPECIFIC
  503.     DATA 243,900243,0,0,0,0,0.2: 'OEM SPECIFIC
  504.     DATA 244,900244,0,0,0,0,0.2: 'OEM SPECIFIC
  505.     DATA 245,900245,0,0,0,0,0.2: 'OEM SPECIFIC
  506.     DATA 246,900246,0,0,0,0,0.2: 'VK_ATTN
  507.     DATA 247,900247,0,0,0,0,0.2: 'VK_ATTN
  508.     DATA 248,900248,0,0,0,0,0.2: 'VK_ATTN
  509.     DATA 249,900249,0,0,0,0,0.2: 'VK_ATTN
  510.     DATA 250,900250,0,0,0,0,0.2: 'VK_ATTN
  511.     DATA 251,900251,0,0,0,0,0.2: 'VK_ATTN
  512.     DATA 252,900252,0,0,0,0,0.2: 'Reserved
  513.     DATA 253,900253,0,0,0,0,0.2: 'VK_PA1
  514.     DATA 254,900253,0,0,0,0,0.2: 'VK_OEM_CLEAR
  515.     DATA 0,0,0,0,0,0,0.2: 'END OF DATA
  516.     AltGr(0) = 165
  517.     AltGr(1) = 0
  518.  
  519.     SELECT CASE Language
  520.         CASE "DE"
  521.             RESTORE Microsoft_windows_cp1250
  522.             FOR i = 128 TO 255
  523.                 READ unicode
  524.                 _MAPUNICODE unicode TO ASCIIcode
  525.             NEXT
  526.             Microsoft_windows_cp1250:
  527.             DATA 8364,0,8218,0,8222,8230,8224,8225,0,8240,352,8249,346,356,381,377
  528.             DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,353,8250,347,357,382,378
  529.             DATA 160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379
  530.             DATA 176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380
  531.             DATA 340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270
  532.             DATA 272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223
  533.             DATA 341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271
  534.             DATA 273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729
  535.             'Remap_KeyCode (Which, ASCII, Ctrl , Shift, Alt, AltGr, Repeat AS _FLOAT)
  536.             Remap_KeyCode 226, 60, 0, 62, 124, 92, 0.2 '<>|
  537.             Remap_KeyCode 219, 225, 0, 63, 0, 0, 0.2 '-
  538.             Remap_KeyCode 48, 48, 0, 61, 0, 125, 0.2 '0
  539.             Remap_KeyCode 192, 148, 0, 153, 0, 0, 0.2
  540.             Remap_KeyCode 222, 132, 0, 142, 0, 0, 0.2
  541.             Remap_KeyCode 50, 50, 0, 34, 0, 253, 0.2: '2 .. I don't see a superscript 3 for AltGr codes for the 3 key.
  542.             Remap_KeyCode 51, 51, 0, 35, 0, 0, 0.2: '3 ..I don't see the squiggle for this in the ASCII code.  It needs to be changed, but I dunno with what.
  543.             Remap_KeyCode 54, 54, 0, 38, 0, 0, 0.2: '6
  544.             Remap_KeyCode 55, 55, 0, 47, 0, 123, 0.2: '7
  545.             Remap_KeyCode 56, 56, 0, 40, 0, 91, 0.2: '8
  546.             Remap_KeyCode 57, 57, 0, 41, 0, 93, 0.2: '9
  547.             Remap_KeyCode 186, 129, 0, 154, 0, 0, 0.2: ';:
  548.             Remap_KeyCode 187, 43, 0, 42, 0, 126, 0.2: '=+
  549.             Remap_KeyCode 191, 35, 0, 249, 0, 0, 0.2: '/?
  550.             Remap_KeyCode 81, 81, 0, 113, 0, 64, 0.2: 'q
  551.             Remap_KeyCode 69, 69, 0, 101, 0, 238, 0.2: 'e
  552.             Remap_KeyCode 77, 77, 0, 109, 0, 0, 0.2: 'm -- again, I failed to find the goofy u which AltGr produces in the 256 ASCII set
  553.  
  554.         CASE "WE"
  555.             RESTORE Microsoft_windows_cp1252
  556.             FOR i = 128 TO 255
  557.                 READ unicode
  558.                 _MAPUNICODE unicode TO ASCIIcode
  559.             NEXT
  560.  
  561.             Microsoft_windows_cp1252:
  562.             DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0
  563.             DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376
  564.             DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  565.             DATA 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  566.             DATA 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
  567.             DATA 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
  568.             DATA 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
  569.             DATA 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
  570.  
  571.  
  572.             'remap_KeyCode (Which, ASCII, Ctrl , Shift, Alt, AltGr, Repeat AS _FLOAT)
  573.             Remap_KeyCode 188, 44, 0, 59, 0, 0, 0.2: ',;
  574.             Remap_KeyCode 190, 46, 0, 58, 0, 0, 0.2: '.:
  575.             Remap_KeyCode 50, 50, 0, 34, 0, 0, 0.2: '2 "
  576.             Remap_KeyCode 51, 51, 0, 156, 0, 0, 0.2: '3 œ
  577.             Remap_KeyCode 191, 151, 0, 21, 0, 0, 0.2: '£ 
  578.             Remap_KeyCode 222, 133, 0, 248, 0, 35, 0.2: '… ø#
  579.             Remap_KeyCode 192, 149, 0, 128, 0, 64, 0.2: '• € @
  580.             Remap_KeyCode 186, 138, 0, 130, 0, 91, 0.2 'Š ‚ [
  581.             Remap_KeyCode 187, 43, 0, 42, 0, 93, 0.2 ' + * ]
  582.             Remap_KeyCode 54, 54, 0, 38, 0, 0, 0.2 '6 &
  583.             Remap_KeyCode 55, 55, 0, 47, 0, 0, 0.2 '7 /
  584.             Remap_KeyCode 56, 56, 0, 40, 0, 0, 0.2 '8(
  585.             Remap_KeyCode 57, 57, 0, 41, 0, 0, 0.2 '9 )
  586.             Remap_KeyCode 48, 48, 0, 61, 0, 0, 0.2 '0 =
  587.             Remap_KeyCode 219, 39, 0, 63, 0, 0, 0.2 ' ' ?
  588.             Remap_KeyCode 221, 141, 0, 94, 0, 0, 0.2 ' ^
  589.             Remap_KeyCode 226, 60, 0, 62, 0, 0, 0.2 '< >
  590.  
  591.         CASE "IT"
  592.  
  593.             RESTORE ASCII_cp850
  594.             FOR i = 128 TO 255
  595.                 READ unicode
  596.                 _MAPUNICODE unicode TO ASCIIcode
  597.             NEXT
  598.  
  599.             ASCII_cp850:
  600.             DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  601.             DATA 201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,402
  602.             DATA 225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187
  603.             DATA 9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488
  604.             DATA 9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164
  605.             DATA 240,208,202,203,200,305,205,206,207,9496,9484,9608,9604,166,204,9600
  606.             DATA 211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180
  607.             DATA 173,177,8215,190,182,167,247,184,176,168,183,185,179,178,9632,160
  608.  
  609.             'remap_KeyCode (Which, ASCII, Ctrl , Shift, Alt, AltGr, Repeat AS _FLOAT)
  610.             Remap_KeyCode 188, 44, 0, 59, 0, 0, 0.2: ',;
  611.             Remap_KeyCode 190, 46, 0, 58, 0, 0, 0.2: '.:
  612.             Remap_KeyCode 50, 50, 0, 34, 0, 0, 0.2: '2 "
  613.             Remap_KeyCode 51, 51, 0, 156, 0, 0, 0.2: '3 œ
  614.             Remap_KeyCode 191, 151, 0, 21, 0, 0, 0.2: '£ 
  615.             Remap_KeyCode 222, 133, 0, 248, 0, 35, 0.2: '… ø#
  616.             Remap_KeyCode 192, 149, 0, 128, 0, 64, 0.2: '• € @
  617.             Remap_KeyCode 186, 138, 0, 130, 0, 91, 0.2 'Š ‚ [
  618.             Remap_KeyCode 187, 43, 0, 42, 0, 93, 0.2 ' + * ]
  619.             Remap_KeyCode 54, 54, 0, 38, 0, 0, 0.2 '6 &
  620.             Remap_KeyCode 55, 55, 0, 47, 0, 0, 0.2 '7 /
  621.             Remap_KeyCode 56, 56, 0, 40, 0, 0, 0.2 '8(
  622.             Remap_KeyCode 57, 57, 0, 41, 0, 0, 0.2 '9 )
  623.             Remap_KeyCode 48, 48, 0, 61, 0, 0, 0.2 '0 =
  624.             Remap_KeyCode 219, 39, 0, 63, 0, 0, 0.2 ' ' ?
  625.             Remap_KeyCode 221, 141, 0, 94, 0, 0, 0.2 ' ^
  626.             Remap_KeyCode 226, 60, 0, 62, 0, 0, 0.2 '< >
  627.     END SELECT
  628.  
  629.  
  630.  
  631. FUNCTION ExtendedTimer##
  632.     'modified extendedtimer to store the old day's count, and not have to recalculate it every time the routine is called.
  633.  
  634.     STATIC olds AS _FLOAT, old_day AS _FLOAT
  635.     DIM m AS INTEGER, d AS INTEGER, y AS INTEGER
  636.     DIM s AS _FLOAT, day AS STRING
  637.     IF olds = 0 THEN 'calculate the day the first time the extended timer runs
  638.         day = DATE$
  639.         m = VAL(LEFT$(day, 2))
  640.         d = VAL(MID$(day, 4, 2))
  641.         y = VAL(RIGHT$(day, 4)) - 1970
  642.         SELECT CASE m 'Add the number of days for each previous month passed
  643.             CASE 2: d = d + 31
  644.             CASE 3: d = d + 59
  645.             CASE 4: d = d + 90
  646.             CASE 5: d = d + 120
  647.             CASE 6: d = d + 151
  648.             CASE 7: d = d + 181
  649.             CASE 8: d = d + 212
  650.             CASE 9: d = d + 243
  651.             CASE 10: d = d + 273
  652.             CASE 11: d = d + 304
  653.             CASE 12: d = d + 334
  654.         END SELECT
  655.         IF (y MOD 4) = 2 AND m > 2 THEN d = d + 1 'add a day if this is leap year and we're past february
  656.         d = (d - 1) + 365 * y 'current month days passed + 365 days per each standard year
  657.         d = d + (y + 2) \ 4 'add in days for leap years passed
  658.         s = d * 24 * 60 * 60 'Seconds are days * 24 hours * 60 minutes * 60 seconds
  659.         old_day = s
  660.     END IF
  661.     IF TIMER < oldt THEN 'we went from 23:59:59 (a second before midnight) to 0:0:0 (midnight)
  662.         old_day = s + 83400 'add another worth of seconds to our counter
  663.     END IF
  664.     oldt = TIMER
  665.     olds = old_day + oldt
  666.     ExtendedTimer## = olds
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673. FUNCTION ExtendedInput$
  674.     SHARED AltGr, Alt, Shift, Ctrl
  675.     PCOPY 0, 1
  676.     A = _AUTODISPLAY: X = POS(0): Y = CSRLIN
  677.     CP = 0: OldCP = 0 'Cursor Position
  678.     _KEYCLEAR
  679.     DO
  680.         PCOPY 1, 0
  681.  
  682.         k = KeyHit
  683.         IF Alt THEN AltDown = -1 ELSE AltDown = 0
  684.         SELECT CASE k 'without alt, add any keypresses to our input
  685.             CASE 8
  686.                 oldin$ = in$
  687.                 IF CP > 0 THEN OldCP = CP: CP = CP - 1
  688.                 in$ = LEFT$(in$, CP) + MID$(in$, CP + 2) 'backspace to erase input
  689.             CASE 9
  690.                 oldin$ = in$
  691.                 in$ = LEFT$(in$, CP) + SPACE$(4) + MID$(in$, CP + 1) 'four spaces for any TAB entered
  692.                 OldCP = CP
  693.                 CP = CP + 4
  694.             CASE 48 TO 57 '0 to 9
  695.                 IF AltDown THEN
  696.                     AltWasDown = -1: alt$ = alt$ + CHR$(k)
  697.                 ELSE
  698.                     oldin$ = in$
  699.                     in$ = LEFT$(in$, CP) + CHR$(k) + MID$(in$, CP + 1) 'add input to our string
  700.                     OldCP = CP
  701.                     CP = CP + 1
  702.                 END IF
  703.             CASE 1 TO 255 'the rest of the ASCII characters
  704.                 IF Ctrl AND (k = 118 OR k = 86) THEN
  705.                     oldin$ = in$
  706.                     in$ = LEFT$(in$, CP) + _CLIPBOARD$ + MID$(in$, CP + 1) 'ctrl-v paste
  707.                     'CTRL-V leaves cursor in position before the paste, without moving it after.
  708.                     'Feel free to modify that behavior here, if you want it to move to after the paste.
  709.                 ELSEIF Ctrl AND (k = 122 OR k = 90) THEN
  710.                     SWAP in$, oldin$: SWAP OldCP, CP 'ctrl-z undo
  711.                 ELSE
  712.                     oldin$ = in$
  713.                     in$ = LEFT$(in$, CP) + CHR$(k) + MID$(in$, CP + 1) 'add input to our string
  714.                     OldCP = CP
  715.                     CP = CP + 1
  716.                 END IF
  717.             CASE 18176 'Home
  718.                 CP = 0
  719.             CASE 20224 'End
  720.                 CP = LEN(in$)
  721.             CASE 21248 'Delete
  722.                 oldin$ = in$
  723.                 in$ = LEFT$(in$, CP) + MID$(in$, CP + 2)
  724.             CASE 19200 'Left
  725.                 CP = CP - 1
  726.                 IF CP < 0 THEN CP = 0
  727.             CASE 19712 'Right
  728.                 CP = CP + 1
  729.                 IF CP > LEN(in$) THEN CP = LEN(in$)
  730.         END SELECT
  731.  
  732.         alt$ = RIGHT$(alt$, 3)
  733.         IF AltWasDown = -1 AND AltDown = 0 THEN
  734.             v = VAL(alt$)
  735.             IF v >= 0 AND v <= 255 THEN in$ = in$ + CHR$(v): CP = CP + 1
  736.             alt$ = "": AltWasDown = 0
  737.         END IF
  738.         blink = (blink + 1) MOD 30
  739.         LOCATE Y, X
  740.         PRINT LEFT$(in$, CP);
  741.         IF blink \ 15 THEN PRINT " "; ELSE PRINT "_";
  742.         PRINT MID$(in$, CP + 1)
  743.  
  744.         _DISPLAY
  745.         _LIMIT 30
  746.     LOOP UNTIL k = 13
  747.  
  748.     PCOPY 1, 0
  749.     LOCATE Y, X: PRINT in$
  750.     ExtendedInput$ = in$
  751.  

It seems like a lot of code, but it's all just my little keyboard library at work here.  I simply unrolled the $INCLUDE statements so that I didn't have to add attachments to the post which anyone had to download and deal with.

Actual working code, for me, would look more like this:

Code: QB64: [Select]
  1. '$INCLUDE:"Keyboard Library.BI'
  2.  
  3.     _LIMIT 120
  4.     k = KeyHit
  5.     IF k <> 0 THEN PRINT k
  6. LOOP UNTIL k = 27
  7.  
  8. '$INCLUDE:'Keyboard Library.BM'

I'm thinking this should probably find all those keys that didn't register (along with some more, such as mouse keys even) for you.  Test it out and let me know how it performs for you guys.  :)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Keyhit codes 173+
« Reply #5 on: November 24, 2020, 09:40:12 pm »
Hi Steve,

Linux user... You are forgiven for calling me a "W" user... 'this' time... lol.  The reference I made earlier (to the 'window' key) was made because I am currently using a MicroSoft branded keyboard...

J
Logic is the beginning of wisdom.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Keyhit codes 173+
« Reply #6 on: November 24, 2020, 10:29:27 pm »
Quote
Since there was keys which _KEYHIT couldn't read for you guys,

Hi Steve,

_KEYHIT was reading OK for keys you inquired about in OP (Original Post), I was getting the same number as you maybe my reply wasn't clear.

I am missing a Stop Key from keyboard so can not confirm 178 or 900178 with that massive bit of code. Yeah with the 700+ LOC thing the numbers returned all had 900xxx where xxx was the same as in OP.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Keyhit codes 173+
« Reply #7 on: November 24, 2020, 10:36:18 pm »
Hi Steve,

_KEYHIT was reading OK for keys you inquired about in OP (Original Post), I was getting the same number as you maybe my reply wasn't clear.

I am missing a Stop Key from keyboard so can not confirm 178 or 900178 with that massive bit of code. Yeah with the 700+ LOC thing the numbers returned all had 900xxx where xxx was the same as in OP.

Ahhh...  I thought you meant that QB64 didn't read the Stop key; not that you didn't have a stop key.  :P

One big difference between the two:  that 700+ line library will read the keys being pressed down, and not just give you a negative code when they're released.  (It also offers support for an extended input routine where you can paste from the clipboard into the input, as well as use arrow keys and other stuff for ease of input and editing, as well as allowing for folks to load custom language keyboards, such as Italian, German, Western Europe, and use them with proper unicode support.)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: Keyhit codes 173+
« Reply #8 on: November 25, 2020, 03:48:51 am »
My Lenovo SL510 laptop has 4 media keys:

                        1st program        2nd program
Volume up:             /175        -900175/900175
Volume down:         /174        -900174/900174

Mute and Microphone Off aren't detected on press or release by either program.
It works better if you plug it in.

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: Keyhit codes 173+
« Reply #9 on: November 26, 2020, 04:19:37 pm »

Mute is -173.
Volume Down is -174.
Volume Up is -175.
Fast Forward is -176.
Rewind is -177.
Stop is -178.
Play/Pause is -179.


Wait.. what keys? Am I missing something I can not find these odd keys of which you speak.
Granted after becoming radioactive I only have a half-life!

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Keyhit codes 173+
« Reply #10 on: November 26, 2020, 05:30:38 pm »
Wait.. what keys? Am I missing something I can not find these odd keys of which you speak.

And I thought I was robbed not having the Stop key, ;)

Mine are sharing keys with the F# keys that are half size already, along the top row (HP Laptop).

Offline STxAxTIC

  • Library Staff
  • Forum Resident
  • Posts: 1091
  • he lives
    • View Profile
Re: Keyhit codes 173+
« Reply #11 on: November 26, 2020, 07:30:16 pm »
Code: QB64: [Select]
  1. Mute is -173.
  2. Volume Down is -174.
  3. Volume Up is -175.
  4. Fast Forward is -176.
  5. Rewind is -177.
  6. [s]Stop is -178.[/s]
  7. Play/Pause is -179.
  8.  

All confirmed except stop button. (i NEVER stop)
You're not done when it works, you're done when it's right.