Author Topic: INKEY$ was unable to capture accented vowels, nor al keyboard symbols  (Read 4439 times)

0 Members and 1 Guest are viewing this topic.

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Contrary to INKEY$ function of Quickbasic, wich performs very well, the INKEY$ function of QB64 was unable to capture accented vowels, like 'áéíóú'.
Also INKEY$ was unable to capture to capture the <AltGr> symbols, and the spanish 'ñ'  or the french 'ç'.
I think this is a bug.
However some maping is posible:
Code: QB64: [Select]
  1. FUNCTION Inkeymap$
  2.   in$ = INKEY$
  3.   IF LEN(in$) THEN
  4.     SELECT CASE ASC(in$)
  5.       CASE 0
  6.         IF LEN(in$) = 2 THEN '...spanish keyboard
  7.           SELECT CASE ASC(in$, 2)
  8.             CASE 26: in$ = "["
  9.             CASE 27: in$ = "]"
  10.             CASE 43: in$ = "\"
  11.             CASE 121: in$ = "@"
  12.             CASE 122: in$ = "#"
  13.             CASE ELSE
  14.           END SELECT
  15.         END IF
  16.       CASE 161: in$ = CHR$(173) '"¡­"
  17.       CASE 170: in$ = CHR$(166) '"ª"
  18.       CASE 186: in$ = CHR$(167) '"º"
  19.       CASE 191: in$ = CHR$(168) '"¿"
  20.       CASE 209: in$ = CHR$(165) '"Ñ"
  21.       CASE 231: in$ = CHR$(128) '"ç"
  22.       CASE 241: in$ = CHR$(164) '"ñ"
  23.       CASE ELSE
  24.     END SELECT
  25.   END IF
  26.   Inkeymap$ = in$
  27.  

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #1 on: April 04, 2019, 04:48:21 pm »
What's the point of this function? Be sure to use _KEYHIT and _MAPUNICODE support with the correct code page and the correct font to support unicode characters. But I also have INKEY$ for Czech after switching the keyboard from English to Czech. Of course, meaningless characters are then displayed. This is just what _MAPUNICODE does. Another disadvantage of INKEY$ is the unability to detect multiple keystrokes at the same time, which in turn resolves _KEYDOWN.

I add my attempt for international support for all languages.

Code: QB64: [Select]
  1. '$include:'nation.bi'
  2. f& = _LOADFONT(ENVIRON$("systemroot") + "\fonts\century.ttf", 20, "monospace")
  3.  
  4.  
  5. PRINT "šěřéíěřé"
  6. PRINT "press national keys for code show:"
  7.     i& = _KEYHIT
  8.     IF i& THEN PRINT "Keyhit code:"; i&
  9.     IF i& < 0 THEN PRINT "released" ' the same code but negative after release
  10.  
  11.     IF INSTR(_OS$, "WINDOWS") THEN WIN = 1 ELSE WIN = 0
  12.  
  13.  

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #2 on: April 05, 2019, 02:08:27 am »
Thanks a lot, Petr. I will test.

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #3 on: April 05, 2019, 09:27:16 am »
Hi Petr
great step toward the internationalization of QB64!
Thanks

PS with this demo I got an error invalid handle at line 3
verifing that ENVIRON$ gives back the right result I have discovered that I have no century.ttf in my font folder!
So changing the name to another TTF (lucon.ttf) i got that your demo runs well.
But I want to see the characters on the screen so I add this little code before the DO...LOOP of your demo
 

Code: QB64: [Select]
  1.  
  2.     CLS
  3.     a$ = INKEY$
  4.     IF a$ = "" THEN PRINT "nothing"; ELSE PRINT a$;
  5.     _DELAY .3
  6. LOOP UNTIL a$ = " "
  7.  
and it works fine
Thanks again
Programming isn't difficult, only it's  consuming time and coffee

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #4 on: April 05, 2019, 02:08:20 pm »
Thank You, TempodiBasic :-D

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #5 on: April 06, 2019, 04:40:31 pm »
I have tested the Petr national spanish code and performs very well.
The problem is that the _keyhit function does not capture the accent keys, so it's imposible to capture a national text from the keyboard, by this function.
Otherside the function keys need to capture the Ctrl, Shift and Alt, to generate a keycode compatible with quickbasic.
Consider this:
Code: QB64: [Select]
  1. '$include:'nation.bi'
  2. f& = _LOADFONT(ENVIRON$("systemroot") + "\fonts\century.ttf", 20, "monospace")
  3.  
  4. PRINT "šěřéíěřé"
  5. PRINT "press national keys for code show:"
  6.   in$ = Inkeyhit$ '...Emulates quickbasic inkey$, except accent's
  7.   IF LEN(in$) THEN PRINT in$;
  8. LOOP UNTIL in$ = CHR$(27)
  9.  
  10. FUNCTION Inkeyhit$ STATIC
  11.   DIM car AS _UNSIGNED _BYTE, doblecar AS STRING * 2
  12.   car = 0
  13.   i& = _KEYHIT
  14.   SELECT CASE i&
  15.     CASE 97 TO 122 'CTRL a-z: 1-26
  16.       car = i&
  17.       keyctrl% = _KEYDOWN(100305) OR _KEYDOWN(100306)
  18.       IF keyctrl% THEN car = car - 96
  19.     CASE 1 TO 255
  20.       car = i&
  21.     CASE 256 TO 65535
  22.       keyalt% = _KEYDOWN(100307) OR _KEYDOWN(100308)
  23.       keyctrl% = _KEYDOWN(100305) OR _KEYDOWN(100306)
  24.       keyshift% = _KEYDOWN(100303) OR _KEYDOWN(100304)
  25.       doblecar = MKI$(i&)
  26.       car = ASC(doblecar, 2)
  27.       IF keyalt% THEN
  28.         SELECT CASE car
  29.           CASE 59 TO 68 'F1-F10: ;-D
  30.             MID$(doblecar, 2) = CHR$(car + 45)
  31.           CASE 133, 134 'F11,F12; …,†
  32.             MID$(doblecar, 2) = CHR$(car + 6)
  33.           CASE ELSE
  34.             car = 0
  35.         END SELECT
  36.       ELSEIF keyctrl% THEN
  37.         SELECT CASE car
  38.           CASE 59 TO 68 'F1-F10: ^-g
  39.             MID$(doblecar, 2) = CHR$(car + 35)
  40.           CASE 71 'Home
  41.             MID$(doblecar, 2) = CHR$(119)
  42.           CASE 73 'RePag
  43.             MID$(doblecar, 2) = CHR$(132)
  44.           CASE 75 'Left
  45.             MID$(doblecar, 2) = CHR$(115)
  46.           CASE 77 'Right
  47.             MID$(doblecar, 2) = CHR$(116)
  48.           CASE 79 'End
  49.             MID$(doblecar, 2) = CHR$(117)
  50.           CASE 81 'AvPag
  51.             MID$(doblecar, 2) = CHR$(118)
  52.           CASE 133, 134 'F11,F12
  53.             MID$(doblecar, 2) = CHR$(car + 4)
  54.           CASE ELSE
  55.             car = 0
  56.         END SELECT
  57.       ELSEIF keyshift% THEN
  58.         SELECT CASE car
  59.           CASE 59 TO 68 'F1-F10
  60.             MID$(doblecar, 2) = CHR$(car + 25)
  61.           CASE 71 TO 81
  62.           CASE 133, 134 'F11,F12
  63.             MID$(doblecar, 2) = CHR$(car + 2)
  64.           CASE ELSE
  65.             car = 0
  66.         END SELECT
  67.       END IF
  68.       IF car THEN Inkeyhit$ = doblecar
  69.       car = 0
  70.  
  71.   IF car THEN Inkeyhit$ = CHR$(car)
  72.  
  73.     IF INSTR(_OS$, "WINDOWS") THEN WIN = 1 ELSE WIN = 0
  74.  
  75.  

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #6 on: April 08, 2019, 03:07:23 am »
Definitively INKEY$ and _KEYHIT have bugs.
INKEY$:
F1-F12 and displacement keys (home, end, arrows...) works OK. Inyect new displacement keys compatible codes for Alt modifier.
bugs:
1) Alt<number of numeric keyboard> not works: some symbols are unavailable, ie greek letters. Without <numlock> do something, but the key 5 have no response, so it's incomplete.
2) Accents not work: áéíóúàâä unavailable.
3) Improper keyboard maping: çÇñÑ¡¿ºª of spanish keyborad shows other symbol, so not available.
4) Incompatible keyboard maping with AltGr keys: î\|@#{}[] shows € + + y z -> <-
The valuable Petr unicode maping aplied to INKEY solves issue 3 with page 1252, and using _KEYHIT solves the issues 3 & 4 (Thank's a lot Petr), but changes the caracter codes, so many symbols adopt new unespected codes, and inyects a new problem with modified (Alt, Ctrl, Shift) F1-F12, displacement keys, and Ctrl a-z. May be solved using _KEYDOWN: See FUNCTION Inkeyhit$.

The following solution has a Inkeyhit$ function that emulates the quickbasic INKEY$, no need a font and preserves the DOS caracter codes. Uses the Petr maping to solve the AltGr codes, but needs some key maping, and accent keys have a extraneous behaviour, so accented letters are not solved (issue 2).
Use Alt numeric keys in the alpha keyboard for caracter codes.

Code: QB64: [Select]
  1. DEFINT H-P
  2. language = 437 'PC, 850 also performs well, 1252 is the windows spanish
  3. CALL MapUnicode(language, page$) 'solves the AltGr issue 4
  4.  
  5. LOCATE , , 1 'show cursor
  6. PRINT "Code page (Language): CP"; page$
  7. PRINT "Inkeyhit & display (128-175): €‚ƒ„ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§©ª«¬­®¯"
  8.   'in$ = INKEY$
  9.   in$ = Inkeyhit$(buf$) 'emulates quickbasic INKEY$, except accents (issue 2)
  10.   IF LEN(in$) THEN PRINT in$;
  11. LOOP UNTIL in$ = CHR$(27)
  12.  
  13. FUNCTION Inkeyhit$ (buf$) STATIC 'Author: Moises1953
  14.   DIM car AS _UNSIGNED _BYTE, doblecar AS STRING * 2
  15.   car = 0
  16.   i& = _KEYHIT
  17.   SELECT CASE i&
  18.     CASE 0 'do nothing
  19.     CASE 48 TO 56 'numeric heys 1-9,0, not numeric keyboard
  20.       keyalt = _KEYDOWN(100307) OR _KEYDOWN(100308)
  21.       IF keyalt THEN
  22.         buf$ = buf$ + CHR$(i&)
  23.         IF LEN(buf$) > 3 THEN buf$ = RIGHT$(buf$, 3)
  24.         car = 0
  25.       ELSE
  26.         car = i&
  27.       END IF
  28.     CASE 97 TO 122 'CTRL a-z: 1-26
  29.       car = i&
  30.       keyctrl = _KEYDOWN(100305) OR _KEYDOWN(100306)
  31.       IF keyctrl THEN car = car - 96
  32.     CASE 128: car = 238 '€î  'spanish keyboard keys maping
  33.     CASE 161: car = 173 '¡­
  34.     CASE 170: car = 166 'ª¦
  35.     CASE 183: car = 249 '·ù
  36.     CASE 186: car = 167 'º§
  37.     CASE 191: car = 168 '¿¨
  38.     CASE 199: car = 128 'ç€
  39.     CASE 209: car = 165 'Ñ¥
  40.     CASE 231: car = 135 'ç‡
  41.     CASE 241: car = 164 'ñ¤
  42.     CASE 1 TO 255
  43.       car = i&
  44.     CASE 256 TO 65535 'double byte chr$(0)+
  45.       keyalt = _KEYDOWN(100307) OR _KEYDOWN(100308)
  46.       keyctrl = _KEYDOWN(100305) OR _KEYDOWN(100306)
  47.       keyshift = _KEYDOWN(100303) OR _KEYDOWN(100304)
  48.       doblecar = MKI$(i&)
  49.       car = ASC(doblecar, 2)
  50.       IF keyalt THEN
  51.         SELECT CASE car
  52.           CASE 59 TO 68 'F1-F10: ;-D
  53.             MID$(doblecar, 2) = CHR$(car + 45)
  54.           CASE 133, 134 'F11,F12; …,†
  55.             MID$(doblecar, 2) = CHR$(car + 6)
  56.           CASE ELSE
  57.             MID$(doblecar, 2) = CHR$(0)
  58.         END SELECT
  59.       ELSEIF keyctrl THEN
  60.         SELECT CASE car
  61.           CASE 59 TO 68 'F1-F10: ^-g
  62.             MID$(doblecar, 2) = CHR$(car + 35)
  63.           CASE 71 'Home
  64.             MID$(doblecar, 2) = CHR$(119)
  65.           CASE 73 'RePag
  66.             MID$(doblecar, 2) = CHR$(132)
  67.           CASE 75 'Left
  68.             MID$(doblecar, 2) = CHR$(115)
  69.           CASE 77 'Right
  70.             MID$(doblecar, 2) = CHR$(116)
  71.           CASE 79 'End
  72.             MID$(doblecar, 2) = CHR$(117)
  73.           CASE 81 'AvPag
  74.             MID$(doblecar, 2) = CHR$(118)
  75.           CASE 133, 134 'F11,F12
  76.             MID$(doblecar, 2) = CHR$(car + 4)
  77.           CASE ELSE
  78.             MID$(doblecar, 2) = CHR$(0)
  79.         END SELECT
  80.       ELSEIF keyshift THEN
  81.         SELECT CASE car
  82.           CASE 59 TO 68 'F1-F10
  83.             MID$(doblecar, 2) = CHR$(car + 25)
  84.           CASE 71 TO 81
  85.           CASE 133, 134 'F11,F12
  86.             MID$(doblecar, 2) = CHR$(car + 2)
  87.           CASE ELSE
  88.             MID$(doblecar, 2) = CHR$(0)
  89.         END SELECT
  90.       END IF
  91.       IF CVI(doblecar) THEN Inkeyhit$ = doblecar
  92.       car = 0
  93.     CASE -100307, -100308 'Alt up
  94.       IF LEN(buf$) THEN
  95.         car = VAL(buf$)
  96.         Inkeyhit$ = CHR$(car)
  97.         buf$ = ""
  98.         car = 0
  99.       END IF
  100.  
  101.   IF car THEN Inkeyhit$ = CHR$(car)
  102.  
  103. SUB MapUnicode (language, page$) 'Derived from Petr maping software (fragment)
  104.   page$ = LTRIM$(STR$(language))
  105.   SELECT CASE language
  106.     CASE 437: RESTORE Microsoft_pc_cp437
  107.     CASE 737: RESTORE Microsoft_pc_cp737
  108.     CASE 775: RESTORE Microsoft_pc_cp775
  109.     CASE 850: RESTORE Microsoft_pc_cp850
  110.     CASE 852: RESTORE Microsoft_pc_cp852
  111.     CASE 855: RESTORE Microsoft_pc_cp855
  112.     CASE 857: RESTORE Microsoft_pc_cp857
  113.     CASE 860: RESTORE Microsoft_pc_cp860
  114.     CASE 861: RESTORE Microsoft_pc_cp861
  115.     CASE 862: RESTORE Microsoft_pc_cp862
  116.     CASE 863: RESTORE Microsoft_pc_cp863
  117.     CASE 864: RESTORE Microsoft_pc_cp864
  118.     CASE 865: RESTORE Microsoft_pc_cp865
  119.     CASE 866: RESTORE Microsoft_pc_cp866
  120.     CASE 869: RESTORE Microsoft_pc_cp869
  121.     CASE 874: RESTORE Microsoft_pc_cp874
  122.     CASE 1250: RESTORE Microsoft_windows_cp1250
  123.     CASE 1251: RESTORE Microsoft_windows_cp1251
  124.     CASE 1252: RESTORE Microsoft_windows_cp1252
  125.     CASE 1253: RESTORE Microsoft_windows_cp1253
  126.     CASE 1254: RESTORE Microsoft_windows_cp1254
  127.     CASE 1255: RESTORE Microsoft_windows_cp1255
  128.     CASE 1256: RESTORE Microsoft_windows_cp1256
  129.     CASE 1257: RESTORE Microsoft_windows_cp1257
  130.     CASE 1258: RESTORE Microsoft_windows_cp1258
  131.     CASE ELSE
  132.       page$ = ""
  133.  
  134.   FOR Icode = 128 TO 255 '...extended ASCII codes
  135.     READ Mapcode
  136.     _MAPUNICODE Mapcode TO Icode
  137.   NEXT
  138.  
  139.   Microsoft_pc_cp437:
  140.   DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  141.   DATA 201,230,198,244,246,242,251,249,255,214,220,162,163,165,8359,402
  142.   DATA 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187
  143.   DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  144.   DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  145.   DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  146.   DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  147.   DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  148.  
  149.   Microsoft_pc_cp737:
  150.   DATA 913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928
  151.   DATA 929,931,932,933,934,935,936,937,945,946,947,948,949,950,951,952
  152.   DATA 953,954,955,956,957,958,959,960,961,963,962,964,965,966,967,968
  153.   DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  154.   DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  155.   DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  156.   DATA 969,940,941,942,970,943,972,973,971,974,902,904,905,906,908,910
  157.   DATA 911,177,8805,8804,938,939,247,8776,176,8729,183,8730,8319,178,9632,160
  158.  
  159.   Microsoft_pc_cp775:
  160.   DATA 262,252,233,257,228,291,229,263,322,275,342,343,299,377,196,197
  161.   DATA 201,230,198,333,246,290,162,346,347,214,220,248,163,216,215,164
  162.   DATA 256,298,243,379,380,378,8221,166,169,174,172,189,188,321,171,187
  163.   DATA 9617,9618,9619,9474,9508,260,268,280,278,9571,9553,9559,9565,302,352,9488
  164.   DATA 9492,9524,9516,9500,9472,9532,370,362,9562,9556,9577,9574,9568,9552,9580,381
  165.   DATA 261,269,281,279,303,353,371,363,382,9496,9484,9608,9604,9612,9616,9600
  166.   DATA 211,223,332,323,245,213,181,324,310,311,315,316,326,274,325,8217
  167.   DATA 173,177,8220,190,182,167,247,8222,176,8729,183,185,179,178,9632,160
  168.  
  169.   Microsoft_pc_cp850:
  170.   DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  171.   DATA 201,230,198,244,246,242,251,249,255,214,220,248,163,216,215,402
  172.   DATA 225,237,243,250,241,209,170,186,191,174,172,189,188,161,171,187
  173.   DATA 9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488
  174.   DATA 9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164
  175.   DATA 240,208,202,203,200,305,205,206,207,9496,9484,9608,9604,166,204,9600
  176.   DATA 211,223,212,210,245,213,181,254,222,218,219,217,253,221,175,180
  177.   DATA 173,177,8215,190,182,167,247,184,176,168,183,185,179,178,9632,160
  178.  
  179.   Microsoft_pc_cp852:
  180.   DATA 199,252,233,226,228,367,263,231,322,235,336,337,238,377,196,262
  181.   DATA 201,313,314,244,246,317,318,346,347,214,220,356,357,321,215,269
  182.   DATA 225,237,243,250,260,261,381,382,280,281,172,378,268,351,171,187
  183.   DATA 9617,9618,9619,9474,9508,193,194,282,350,9571,9553,9559,9565,379,380,9488
  184.   DATA 9492,9524,9516,9500,9472,9532,258,259,9562,9556,9577,9574,9568,9552,9580,164
  185.   DATA 273,272,270,203,271,327,205,206,283,9496,9484,9608,9604,354,366,9600
  186.   DATA 211,223,212,323,324,328,352,353,340,218,341,368,253,221,355,180
  187.   DATA 173,733,731,711,728,167,247,184,176,168,729,369,344,345,9632,160
  188.  
  189.   Microsoft_pc_cp855:
  190.   DATA 1106,1026,1107,1027,1105,1025,1108,1028,1109,1029,1110,1030,1111,1031,1112,1032
  191.   DATA 1113,1033,1114,1034,1115,1035,1116,1036,1118,1038,1119,1039,1102,1070,1098,1066
  192.   DATA 1072,1040,1073,1041,1094,1062,1076,1044,1077,1045,1092,1060,1075,1043,171,187
  193.   DATA 9617,9618,9619,9474,9508,1093,1061,1080,1048,9571,9553,9559,9565,1081,1049,9488
  194.   DATA 9492,9524,9516,9500,9472,9532,1082,1050,9562,9556,9577,9574,9568,9552,9580,164
  195.   DATA 1083,1051,1084,1052,1085,1053,1086,1054,1087,9496,9484,9608,9604,1055,1103,9600
  196.   DATA 1071,1088,1056,1089,1057,1090,1058,1091,1059,1078,1046,1074,1042,1100,1068,8470
  197.   DATA 173,1099,1067,1079,1047,1096,1064,1101,1069,1097,1065,1095,1063,167,9632,160
  198.  
  199.   Microsoft_pc_cp857:
  200.   DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,305,196,197
  201.   DATA 201,230,198,244,246,242,251,249,304,214,220,248,163,216,350,351
  202.   DATA 225,237,243,250,241,209,286,287,191,174,172,189,188,161,171,187
  203.   DATA 9617,9618,9619,9474,9508,193,194,192,169,9571,9553,9559,9565,162,165,9488
  204.   DATA 9492,9524,9516,9500,9472,9532,227,195,9562,9556,9577,9574,9568,9552,9580,164
  205.   DATA 186,170,202,203,200,0,205,206,207,9496,9484,9608,9604,166,204,9600
  206.   DATA 211,223,212,210,245,213,181,0,215,218,219,217,236,255,175,180
  207.   DATA 173,177,0,190,182,167,247,184,176,168,183,185,179,178,9632,160
  208.  
  209.   Microsoft_pc_cp860:
  210.   DATA 199,252,233,226,227,224,193,231,234,202,232,205,212,236,195,194
  211.   DATA 201,192,200,244,245,242,218,249,204,213,220,162,163,217,8359,211
  212.   DATA 225,237,243,250,241,209,170,186,191,210,172,189,188,161,171,187
  213.   DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  214.   DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  215.   DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  216.   DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  217.   DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  218.  
  219.   Microsoft_pc_cp861:
  220.   DATA 199,252,233,226,228,224,229,231,234,235,232,208,240,222,196,197
  221.   DATA 201,230,198,244,246,254,251,221,253,214,220,248,163,216,8359,402
  222.   DATA 225,237,243,250,193,205,211,218,191,8976,172,189,188,161,171,187
  223.   DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  224.   DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  225.   DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  226.   DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  227.   DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  228.  
  229.   Microsoft_pc_cp862:
  230.   DATA 1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503
  231.   DATA 1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,162,163,165,8359,402
  232.   DATA 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,187
  233.   DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  234.   DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  235.   DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  236.   DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  237.   DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  238.  
  239.   Microsoft_pc_cp863:
  240.   DATA 199,252,233,226,194,224,182,231,234,235,232,239,238,8215,192,167
  241.   DATA 201,200,202,244,203,207,251,249,164,212,220,162,163,217,219,402
  242.   DATA 166,180,243,250,168,184,179,175,206,8976,172,189,188,190,171,187
  243.   DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  244.   DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  245.   DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  246.   DATA 4023,945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  247.   DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  248.  
  249.   Microsoft_pc_cp864:
  250.   DATA 176,183,8729,8730,9618,9472,9474,9532,9508,9516,9500,9524,9488,9484,9492,9496
  251.   DATA 946,8734,966,177,189,188,8776,171,187,65271,65272,0,0,65275,65276,0
  252.   DATA 160,173,65154,163,164,65156,0,0,65166,65167,65173,65177,1548,65181,65185,65189
  253.   DATA 1632,1633,1634,1635,1636,1637,1638,1639,1640,1641,65233,1563,65201,65205,65209,1567
  254.   DATA 162,65152,65153,65155,65157,65226,65163,65165,65169,65171,65175,65179,65183,65187,65191,65193
  255.   DATA 65195,65197,65199,65203,65207,65211,65215,65217,65221,65227,65231,166,172,247,215,65225
  256.   DATA 1600,65235,65239,65243,65247,65251,65255,65259,65261,65263,65267,65213,65228,65230,65229,65249
  257.   DATA 65149,1617,65253,65257,65260,65264,65266,65232,65237,65269,65270,65245,65241,65265,9632,0
  258.  
  259.   Microsoft_pc_cp865:
  260.   DATA 199,252,233,226,228,224,229,231,234,235,232,239,238,236,196,197
  261.   DATA 201,230,198,244,246,242,251,249,255,214,220,248,163,216,8359,402
  262.   DATA 225,237,243,250,241,209,170,186,191,8976,172,189,188,161,171,164
  263.   DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  264.   DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  265.   DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  266.   DATA 945,223,915,960,931,963,181,964,934,920,937,948,8734,966,949,8745
  267.   DATA 8801,177,8805,8804,8992,8993,247,8776,176,8729,183,8730,8319,178,9632,160
  268.  
  269.   Microsoft_pc_cp866:
  270.   DATA 1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055
  271.   DATA 1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071
  272.   DATA 1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087
  273.   DATA 9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488
  274.   DATA 9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575
  275.   DATA 9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600
  276.   DATA 1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103
  277.   DATA 1025,1105,1028,1108,1031,1111,1038,1118,176,8729,183,8730,8470,164,9632,160
  278.  
  279.   Microsoft_pc_cp869:
  280.   DATA 0,0,0,0,0,0,902,0,183,172,166,8216,8217,904,8213,905
  281.   DATA 906,938,908,0,0,910,939,169,911,178,179,940,163,941,942,943
  282.   DATA 970,912,972,973,913,914,915,916,917,918,919,189,920,921,171,187
  283.   DATA 9617,9618,9619,9474,9508,922,923,924,925,9571,9553,9559,9565,926,927,9488
  284.   DATA 9492,9524,9516,9500,9472,9532,928,929,9562,9556,9577,9574,9568,9552,9580,931
  285.   DATA 932,933,934,935,936,937,945,946,947,9496,9484,9608,9604,948,949,9600
  286.   DATA 950,951,952,953,954,955,956,957,958,959,960,961,963,962,964,900
  287.   DATA 173,177,965,966,967,167,968,901,176,168,969,971,944,974,9632,160
  288.  
  289.   Microsoft_pc_cp874:
  290.   DATA 8364,0,0,0,0,8230,0,0,0,0,0,0,0,0,0,0
  291.   DATA 0,8216,8217,8220,8221,8226,8211,8212,0,0,0,0,0,0,0,0
  292.   DATA 160,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599
  293.   DATA 3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615
  294.   DATA 3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631
  295.   DATA 3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,0,0,0,0,3647
  296.   DATA 3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663
  297.   DATA 3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,0,0,0,0
  298.  
  299.   Microsoft_windows_cp1250:
  300.   DATA 8364,0,8218,0,8222,8230,8224,8225,0,8240,352,8249,346,356,381,377
  301.   DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,353,8250,347,357,382,378
  302.   DATA 160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379
  303.   DATA 176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380
  304.   DATA 340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270
  305.   DATA 272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223
  306.   DATA 341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271
  307.   DATA 273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729
  308.  
  309.   Microsoft_windows_cp1251:
  310.   DATA 1026,1027,8218,1107,8222,8230,8224,8225,8364,8240,1033,8249,1034,1036,1035,1039
  311.   DATA 1106,8216,8217,8220,8221,8226,8211,8212,0,8482,1113,8250,1114,1116,1115,1119
  312.   DATA 160,1038,1118,1032,164,1168,166,167,1025,169,1028,171,172,173,174,1031
  313.   DATA 176,177,1030,1110,1169,181,182,183,1105,8470,1108,187,1112,1029,1109,1111
  314.   DATA 1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055
  315.   DATA 1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071
  316.   DATA 1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087
  317.   DATA 1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103
  318.  
  319.   Microsoft_windows_cp1252:
  320.   DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,381,0
  321.   DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,382,376
  322.   DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  323.   DATA 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  324.   DATA 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
  325.   DATA 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
  326.   DATA 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
  327.   DATA 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
  328.  
  329.   Microsoft_windows_cp1253:
  330.   DATA 8364,0,8218,402,8222,8230,8224,8225,0,8240,0,8249,0,0,0,0
  331.   DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,0,8250,0,0,0,0
  332.   DATA 160,901,902,163,164,165,166,167,168,169,0,171,172,173,174,8213
  333.   DATA 176,177,178,179,900,181,182,183,904,905,906,187,908,189,910,911
  334.   DATA 912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927
  335.   DATA 928,929,0,931,932,933,934,935,936,937,938,939,940,941,942,943
  336.   DATA 944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959
  337.   DATA 960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,0
  338.  
  339.   Microsoft_windows_cp1254:
  340.   DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,0,0,0
  341.   DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,0,0,376
  342.   DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  343.   DATA 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  344.   DATA 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
  345.   DATA 286,209,210,211,212,213,214,215,216,217,218,219,220,304,350,223
  346.   DATA 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
  347.   DATA 287,241,242,243,244,245,246,247,248,249,250,251,252,305,351,255
  348.  
  349.   Microsoft_windows_cp1255:
  350.   DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,0,8249,0,0,0,0
  351.   DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,0,8250,0,0,0,0
  352.   DATA 160,161,162,163,8362,165,166,167,168,169,215,171,172,173,174,175
  353.   DATA 176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,191
  354.   DATA 1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,0,1467,1468,1469,1470,1471
  355.   DATA 1472,1473,1474,1475,1520,1521,1522,1523,1524,0,0,0,0,0,0,0
  356.   DATA 1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503
  357.   DATA 1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,0,0,8206,8207,0
  358.  
  359.   Microsoft_windows_cp1256:
  360.   DATA 8364,1662,8218,402,8222,8230,8224,8225,710,8240,1657,8249,338,1670,1688,1672
  361.   DATA 1711,8216,8217,8220,8221,8226,8211,8212,1705,8482,1681,8250,339,8204,8205,1722
  362.   DATA 160,1548,162,163,164,165,166,167,168,169,1726,171,172,173,174,175
  363.   DATA 176,177,178,179,180,181,182,183,184,185,1563,187,188,189,190,1567
  364.   DATA 1729,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583
  365.   DATA 1584,1585,1586,1587,1588,1589,1590,215,1591,1592,1593,1594,1600,1601,1602,1603
  366.   DATA 224,1604,226,1605,1606,1607,1608,231,232,233,234,235,1609,1610,238,239
  367.   DATA 1611,1612,1613,1614,244,1615,1616,247,1617,249,1618,251,252,8206,8207,1746
  368.  
  369.   Microsoft_windows_cp1257:
  370.   DATA 8364,0,8218,0,8222,8230,8224,8225,0,8240,0,8249,0,168,711,184
  371.   DATA 0,8216,8217,8220,8221,8226,8211,8212,0,8482,0,8250,0,175,731,0
  372.   DATA 160,0,162,163,164,0,166,167,216,169,342,171,172,173,174,198
  373.   DATA 176,177,178,179,180,181,182,183,248,185,343,187,188,189,190,230
  374.   DATA 260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315
  375.   DATA 352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223
  376.   DATA 261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316
  377.   DATA 353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,729
  378.  
  379.   Microsoft_windows_cp1258:
  380.   DATA 8364,0,8218,402,8222,8230,8224,8225,710,8240,0,8249,338,0,0,0
  381.   DATA 0,8216,8217,8220,8221,8226,8211,8212,732,8482,0,8250,339,0,0,376
  382.   DATA 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
  383.   DATA 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
  384.   DATA 192,193,194,258,196,197,198,199,200,201,202,203,768,205,206,207
  385.   DATA 272,209,777,211,212,416,214,215,216,217,218,219,220,431,771,223
  386.   DATA 224,225,226,259,228,229,230,231,232,233,234,235,769,237,238,239
  387.   DATA 273,241,803,243,244,417,246,247,248,249,250,251,252,432,8363,255
  388.  
  389.  

Offline RhoSigma

  • QB64 Developer
  • Forum Resident
  • Posts: 565
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #7 on: April 08, 2019, 06:09:31 am »
Try this one, i made this for use in Germany, maybe its working for other countries too:

EDIT: post & codebox deleted (turned out to buggy either)
« Last Edit: April 09, 2019, 01:00:48 pm by RhoSigma »
My Projects:   https://qb64forum.alephc.xyz/index.php?topic=809
GuiTools - A graphic UI framework (can do multiple UI forms/windows in one program)
Libraries - ImageProcess, StringBuffers (virt. files), MD5/SHA2-Hash, LZW etc.
Bonus - Blankers, QB64/Notepad++ setup pack

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #8 on: April 10, 2019, 05:34:59 am »
This in my definitive version of Inkeyhit$ function, including accented vowels.
No need font's, nor mapings, but can not represent all chars, but only the standard 437 code page.
Code: QB64: [Select]
  1. FUNCTION Inkeyhit$ STATIC 'Author: Moises1953
  2.   DIM car AS _UNSIGNED _BYTE, doblecar AS STRING * 2
  3.   car = 0
  4.   i& = _KEYHIT
  5.   keyalt = _KEYDOWN(100307) OR _KEYDOWN(100308)
  6.   keyctrl = _KEYDOWN(100305) OR _KEYDOWN(100306)
  7.   keyshift = _KEYDOWN(100303) OR _KEYDOWN(100304)
  8.  
  9.   SELECT CASE i&
  10.     CASE 0 'do nothing
  11.     CASE 48 TO 57 'numeric heys 0-9, not numeric keyboard
  12.       IF keyalt THEN
  13.         buf$ = buf$ + CHR$(i&)
  14.         IF LEN(buf$) > 3 THEN buf$ = RIGHT$(buf$, 3)
  15.         car = 0
  16.       ELSE
  17.         car = i&
  18.       END IF
  19.     CASE 97 TO 122 'CTRL a-z: 1-26
  20.       car = i&
  21.       IF keyctrl THEN
  22.         car = car - 96
  23.       ELSEIF iaccent THEN '...accented vowels
  24.         SELECT CASE iaccent
  25.           CASE 1
  26.             SELECT CASE i&
  27.               CASE 97: car = 160 '
  28.               CASE 101: car = 130 '‚
  29.               CASE 105: car = 161
  30.               CASE 111: car = 162
  31.               CASE 117: car = 163
  32.             END SELECT
  33.           CASE 2
  34.             SELECT CASE i&
  35.               CASE 97: car = 133 '…
  36.               CASE 101: car = 138
  37.               CASE 105: car = 141
  38.               CASE 111: car = 149 '•
  39.               CASE 117: car = 151 '—
  40.             END SELECT
  41.           CASE 3
  42.             SELECT CASE i&
  43.               CASE 97: car = 132 '„
  44.               CASE 101: car = 137 '‰
  45.               CASE 105: car = 139 '‹
  46.               CASE 111: car = 148 '”
  47.               CASE 117: car = 129
  48.             END SELECT
  49.           CASE 4
  50.             SELECT CASE i&
  51.               CASE 97: car = 131
  52.               CASE 101: car = 136
  53.               CASE 105: car = 140
  54.               CASE 111: car = 147 '“
  55.               CASE 117: car = 150 '–
  56.             END SELECT
  57.         END SELECT
  58.         iaccent = 0
  59.       END IF
  60.     CASE 128: car = 238 '€î   'spanish keyboard keys maping
  61.     CASE 161: car = 173 '¡­
  62.     CASE 170: car = 166 'ª¦
  63.     CASE 183: car = 249 '·ù
  64.     CASE 186: car = 167 'º§
  65.     CASE 191: car = 168 '¿¨
  66.     CASE 199: car = 128 'ç€
  67.     CASE 209: car = 165 'Ñ¥
  68.     CASE 231: car = 135 'ç‡
  69.     CASE 241: car = 164 'ñ¤
  70.     CASE 1 TO 255
  71.       car = i&
  72.     CASE 256 TO 65535 'double byte chr$(0)+
  73.       doblecar = MKI$(i&)
  74.       car = ASC(doblecar, 2)
  75.       IF keyalt THEN
  76.         SELECT CASE car
  77.           CASE 59 TO 68 'F1-F10: ;-D
  78.             MID$(doblecar, 2) = CHR$(car + 45)
  79.           CASE 133, 134 'F11,F12; …,†
  80.             MID$(doblecar, 2) = CHR$(car + 6)
  81.           CASE ELSE
  82.             MID$(doblecar, 2) = CHR$(0)
  83.         END SELECT
  84.       ELSEIF keyctrl THEN
  85.         SELECT CASE car
  86.           CASE 59 TO 68 'F1-F10: ^-g
  87.             MID$(doblecar, 2) = CHR$(car + 35)
  88.           CASE 71 'Home
  89.             MID$(doblecar, 2) = CHR$(119)
  90.           CASE 73 'RePag
  91.             MID$(doblecar, 2) = CHR$(132)
  92.           CASE 75 'Left
  93.             MID$(doblecar, 2) = CHR$(115)
  94.           CASE 77 'Right
  95.             MID$(doblecar, 2) = CHR$(116)
  96.           CASE 79 'End
  97.             MID$(doblecar, 2) = CHR$(117)
  98.           CASE 81 'AvPag
  99.             MID$(doblecar, 2) = CHR$(118)
  100.           CASE 133, 134 'F11,F12
  101.             MID$(doblecar, 2) = CHR$(car + 4)
  102.           CASE ELSE
  103.             MID$(doblecar, 2) = CHR$(0)
  104.         END SELECT
  105.       ELSEIF keyshift THEN
  106.         SELECT CASE car
  107.           CASE 59 TO 68 'F1-F10
  108.             MID$(doblecar, 2) = CHR$(car + 25)
  109.           CASE 71 TO 81
  110.           CASE 133, 134 'F11,F12
  111.             MID$(doblecar, 2) = CHR$(car + 2)
  112.           CASE ELSE
  113.             MID$(doblecar, 2) = CHR$(0)
  114.         END SELECT
  115.       END IF
  116.       IF CVI(doblecar) THEN Inkeyhit$ = doblecar
  117.       car = 0
  118.     CASE -100308 'Alt up
  119.       IF LEN(buf$) THEN
  120.         car = VAL(buf$)
  121.         Inkeyhit$ = CHR$(car)
  122.         buf$ = ""
  123.         car = 0
  124.       END IF
  125.     CASE -222 'accent and dieresis
  126.       IF keyshift THEN
  127.         iaccent = 3
  128.       ELSE
  129.         iaccent = 1
  130.       END IF
  131.     CASE -186 'backaccent and circumflex
  132.       IF keyshift THEN
  133.         iaccent = 4
  134.       ELSE
  135.         iaccent = 2
  136.       END IF
  137.   IF car THEN Inkeyhit$ = CHR$(car)

Offline moises1953

  • Newbie
  • Posts: 55
    • View Profile
Re: INKEY$ was unable to capture accented vowels, nor al keyboard symbols
« Reply #9 on: April 13, 2019, 03:07:37 pm »
This version also works with alt <number> if numlock is activated.
Includes the test program with font, no unicode.
Code: QB64: [Select]
  1. DEFINT H-P
  2. 'fontpath$ = "LessPerfectDOSVGA.ttf" 'http://laemeur.sdf.org/fonts/
  3. fontpath$ = "lucon.ttf" 'lucida console
  4. fontsize% = 16
  5. style$ = "MONOSPACE"
  6. font& = _LOADFONT(fontpath$, fontsize%, style$)
  7. IF font& THEN _FONT font&
  8.  
  9. LOCATE , , 1 'show cursor
  10. PRINT "Inkeyhit & display (128-175): €‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯"
  11. PRINT "                   (176-223): °±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞß"
  12. PRINT "CP437 extended     (224-254): àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþ"
  13.   in$ = Inkeyhit$ 'emulates quickbasic INKEY$
  14.   IF LEN(in$) THEN PRINT in$;
  15. LOOP UNTIL in$ = CHR$(27)
  16.  
  17. FUNCTION Inkeyhit$ STATIC 'Author: Moises1953
  18.   DIM car AS _UNSIGNED _BYTE, doblecar AS STRING * 2
  19.   i& = _KEYHIT
  20.   IF i& THEN
  21.     car = 0
  22.     keyalt = _KEYDOWN(100307) OR _KEYDOWN(100308)
  23.     keyctrl = _KEYDOWN(100305) OR _KEYDOWN(100306)
  24.     keyshift = _KEYDOWN(100303) OR _KEYDOWN(100304)
  25.  
  26.     SELECT CASE i&
  27.       CASE 48 TO 57 'numeric heys 0-9
  28.         IF keyalt = 0 THEN car = i&
  29.       CASE 97 TO 122 'CTRL a-z: 1-26
  30.         car = i&
  31.         IF keyctrl THEN
  32.           car = car - 96
  33.         ELSEIF iaccent THEN '...accented vowels
  34.           SELECT CASE iaccent
  35.             CASE 1
  36.               SELECT CASE i&
  37.                 CASE 97: car = 160 '
  38.                 CASE 101: car = 130 '‚
  39.                 CASE 105: car = 161
  40.                 CASE 111: car = 162
  41.                 CASE 117: car = 163
  42.               END SELECT
  43.             CASE 2
  44.               SELECT CASE i&
  45.                 CASE 97: car = 133 '…
  46.                 CASE 101: car = 138
  47.                 CASE 105: car = 141
  48.                 CASE 111: car = 149 '•
  49.                 CASE 117: car = 151 '—
  50.               END SELECT
  51.             CASE 3
  52.               SELECT CASE i&
  53.                 CASE 97: car = 132 '„
  54.                 CASE 101: car = 137 '‰
  55.                 CASE 105: car = 139 '‹
  56.                 CASE 111: car = 148 '”
  57.                 CASE 117: car = 129
  58.               END SELECT
  59.             CASE 4
  60.               SELECT CASE i&
  61.                 CASE 97: car = 131
  62.                 CASE 101: car = 136
  63.                 CASE 105: car = 140
  64.                 CASE 111: car = 147 '“
  65.                 CASE 117: car = 150 '–
  66.               END SELECT
  67.           END SELECT
  68.         END IF
  69.       CASE 128: car = 238 '€î   'spanish keyboard keys maping
  70.       CASE 161: car = 173 '¡­
  71.       CASE 170: car = 166 'ª¦
  72.       CASE 183: car = 249 '·ù
  73.       CASE 186: car = 167 'º§
  74.       CASE 191: car = 168 '¿¨
  75.       CASE 199: car = 128 'ç€
  76.       CASE 209: car = 165 'Ñ¥
  77.       CASE 231: car = 135 'ç‡
  78.       CASE 241: car = 164 'ñ¤
  79.       CASE 1 TO 255
  80.         car = i&
  81.       CASE 256 TO 65535 'double byte chr$(0)+
  82.         doblecar = MKI$(i&)
  83.         car = ASC(doblecar, 2)
  84.         IF keyalt THEN
  85.           SELECT CASE car
  86.             CASE 59 TO 68 'F1-F10: ;-D
  87.               MID$(doblecar, 2) = CHR$(car + 45)
  88.             CASE 133, 134 'F11,F12; …,†
  89.               MID$(doblecar, 2) = CHR$(car + 6)
  90.             CASE ELSE
  91.               MID$(doblecar, 2) = CHR$(0)
  92.           END SELECT
  93.         ELSEIF keyctrl THEN
  94.           SELECT CASE car
  95.             CASE 59 TO 68 'F1-F10: ^-g
  96.               MID$(doblecar, 2) = CHR$(car + 35)
  97.             CASE 71 'Home
  98.               MID$(doblecar, 2) = CHR$(119)
  99.             CASE 73 'RePag
  100.               MID$(doblecar, 2) = CHR$(132)
  101.             CASE 75 'Left
  102.               MID$(doblecar, 2) = CHR$(115)
  103.             CASE 77 'Right
  104.               MID$(doblecar, 2) = CHR$(116)
  105.             CASE 79 'End
  106.               MID$(doblecar, 2) = CHR$(117)
  107.             CASE 81 'AvPag
  108.               MID$(doblecar, 2) = CHR$(118)
  109.             CASE 133, 134 'F11,F12
  110.               MID$(doblecar, 2) = CHR$(car + 4)
  111.             CASE ELSE
  112.               MID$(doblecar, 2) = CHR$(0)
  113.           END SELECT
  114.         ELSEIF keyshift THEN
  115.           SELECT CASE car
  116.             CASE 59 TO 68 'F1-F10
  117.               MID$(doblecar, 2) = CHR$(car + 25)
  118.             CASE 71 TO 81
  119.             CASE 133, 134 'F11,F12
  120.               MID$(doblecar, 2) = CHR$(car + 2)
  121.             CASE ELSE
  122.               MID$(doblecar, 2) = CHR$(0)
  123.           END SELECT
  124.         END IF
  125.         IF CVI(doblecar) THEN
  126.           Inkeyhit$ = doblecar
  127.           iaccent = 0
  128.         END IF
  129.         car = 0
  130.       CASE -100308 'Alt up
  131.         IF LEN(buf$) THEN
  132.           car = VAL(buf$)
  133.           buf$ = ""
  134.         END IF
  135.       CASE -222 'accent and dieresis
  136.         IF keyshift THEN
  137.           iaccent = 3
  138.         ELSE
  139.           iaccent = 1
  140.         END IF
  141.       CASE -186 'backaccent and circumflex
  142.         IF keyshift THEN
  143.           iaccent = 4
  144.         ELSE
  145.           iaccent = 2
  146.         END IF
  147.       CASE -57 TO -48 'numeric keys, also numeric keypad with numlock
  148.         IF keyalt THEN
  149.           IF LEN(buf$) > 2 THEN buf$ = RIGHT$(buf$, 2)
  150.           buf$ = buf$ + CHR$(ABS(i&))
  151.         END IF
  152.     END SELECT
  153.     IF car THEN
  154.       Inkeyhit$ = CHR$(car)
  155.       iaccent = 0
  156.     END IF
  157.   END IF
  158.  
« Last Edit: April 13, 2019, 03:41:49 pm by moises1953 »