Browse Source

* merged all changes from ptc trunk from sourceforge; adds support for different
keyboard input modes in ptccrt (TP7 compatible, GO32 CRT compatible and WIN32
CRT compatible mode)

git-svn-id: trunk@36555 -

nickysn 8 years ago
parent
commit
a217c4c7d0

+ 5 - 0
.gitattributes

@@ -7030,6 +7030,11 @@ packages/ptc/src/x11/x11unikey.inc svneol=native#text/plain
 packages/ptc/src/x11/x11windowdisplayd.inc svneol=native#text/plain
 packages/ptc/src/x11/x11windowdisplayd.inc svneol=native#text/plain
 packages/ptc/src/x11/x11windowdisplayi.inc svneol=native#text/plain
 packages/ptc/src/x11/x11windowdisplayi.inc svneol=native#text/plain
 packages/ptc/tests/convtest.pp svneol=native#text/plain
 packages/ptc/tests/convtest.pp svneol=native#text/plain
+packages/ptc/tests/crtkeys/crtkeys.pas svneol=native#text/plain
+packages/ptc/tests/crtkeys/crtkeys_fpwincrt.txt svneol=native#text/plain
+packages/ptc/tests/crtkeys/crtkeys_go32v2.txt svneol=native#text/plain
+packages/ptc/tests/crtkeys/crtkeys_tp7.txt svneol=native#text/plain
+packages/ptc/tests/crtkeys/ptccrtkeys.pas svneol=native#text/plain
 packages/ptc/tests/endian.inc svneol=native#text/plain
 packages/ptc/tests/endian.inc svneol=native#text/plain
 packages/ptc/tests/event.pp svneol=native#text/plain
 packages/ptc/tests/event.pp svneol=native#text/plain
 packages/ptc/tests/view.pp svneol=native#text/plain
 packages/ptc/tests/view.pp svneol=native#text/plain

+ 197 - 3
packages/graph/src/ptcgraph/ptccrt.pp

@@ -1,6 +1,6 @@
 {
 {
     This file is part of the Free Pascal run time library.
     This file is part of the Free Pascal run time library.
-    Copyright (c) 2010, 2011, 2013 by Nikolay Nikolov ([email protected])
+    Copyright (c) 2010, 2011, 2013, 2017 by Nikolay Nikolov ([email protected])
 
 
     This file implements keyboard input support for ptcgraph
     This file implements keyboard input support for ptcgraph
 
 
@@ -35,10 +35,12 @@ type
 {$ELSE HasCRT}
 {$ELSE HasCRT}
   tcrtcoord = 1..255;
   tcrtcoord = 1..255;
 {$ENDIF HasCRT}
 {$ENDIF HasCRT}
+  tkeymode = (kmTP7, kmGO32, kmFPWINCRT);
 
 
 var
 var
   DirectVideo: Boolean {$IFDEF HasCRT}absolute crt.DirectVideo{$ENDIF HasCRT};
   DirectVideo: Boolean {$IFDEF HasCRT}absolute crt.DirectVideo{$ENDIF HasCRT};
   TextAttr: Byte {$IFDEF HasCRT}absolute crt.TextAttr{$ENDIF HasCRT};
   TextAttr: Byte {$IFDEF HasCRT}absolute crt.TextAttr{$ENDIF HasCRT};
+  KeyMode: TKeyMode = kmTP7;
 
 
 function KeyPressed: Boolean;
 function KeyPressed: Boolean;
 function ReadKey: Char;
 function ReadKey: Char;
@@ -132,6 +134,9 @@ begin
               if KeyEv.Alt then
               if KeyEv.Alt then
               begin
               begin
                 case KeyEv.Code of
                 case KeyEv.Code of
+                  PTCKEY_ESCAPE:
+                    if KeyMode = kmGO32 then
+                      KeyBufAdd(#0#1);
                   PTCKEY_F1:     KeyBufAdd(#0#104);
                   PTCKEY_F1:     KeyBufAdd(#0#104);
                   PTCKEY_F2:     KeyBufAdd(#0#105);
                   PTCKEY_F2:     KeyBufAdd(#0#105);
                   PTCKEY_F3:     KeyBufAdd(#0#106);
                   PTCKEY_F3:     KeyBufAdd(#0#106);
@@ -142,6 +147,12 @@ begin
                   PTCKEY_F8:     KeyBufAdd(#0#111);
                   PTCKEY_F8:     KeyBufAdd(#0#111);
                   PTCKEY_F9:     KeyBufAdd(#0#112);
                   PTCKEY_F9:     KeyBufAdd(#0#112);
                   PTCKEY_F10:    KeyBufAdd(#0#113);
                   PTCKEY_F10:    KeyBufAdd(#0#113);
+                  PTCKEY_F11:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#139);
+                  PTCKEY_F12:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#140);
                   PTCKEY_ONE:    KeyBufAdd(#0#120);
                   PTCKEY_ONE:    KeyBufAdd(#0#120);
                   PTCKEY_TWO:    KeyBufAdd(#0#121);
                   PTCKEY_TWO:    KeyBufAdd(#0#121);
                   PTCKEY_THREE:  KeyBufAdd(#0#122);
                   PTCKEY_THREE:  KeyBufAdd(#0#122);
@@ -180,6 +191,89 @@ begin
                   PTCKEY_B:      KeyBufAdd(#0#48);
                   PTCKEY_B:      KeyBufAdd(#0#48);
                   PTCKEY_N:      KeyBufAdd(#0#49);
                   PTCKEY_N:      KeyBufAdd(#0#49);
                   PTCKEY_M:      KeyBufAdd(#0#50);
                   PTCKEY_M:      KeyBufAdd(#0#50);
+                  PTCKEY_BACKQUOTE:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#41);
+                  PTCKEY_BACKSPACE:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#14);
+                  PTCKEY_TAB:
+                    if KeyMode = kmGO32 then
+                      KeyBufAdd(#0#165);
+                  PTCKEY_OPENBRACKET:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#26);
+                  PTCKEY_CLOSEBRACKET:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#27);
+                  PTCKEY_BACKSLASH:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#43);
+                  PTCKEY_SEMICOLON:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#39);
+                  PTCKEY_QUOTE:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#40);
+                  PTCKEY_ENTER:
+                    if KeyMode = kmGO32 then
+                      if pmkNumPadKey in KeyEv.ModifierKeys then
+                        KeyBufAdd(#0#166)
+                      else
+                        KeyBufAdd(#0#28);
+                  PTCKEY_COMMA:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#51);
+                  PTCKEY_PERIOD:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#52);
+                  PTCKEY_SLASH:
+                    if KeyMode = kmFPWINCRT then
+                      KeyBufAdd(#0#164)
+                    else if KeyMode = kmGO32 then
+                      KeyBufAdd(#0#53);
+                  PTCKEY_INSERT:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#162);
+                  PTCKEY_DELETE:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#163);
+                  PTCKEY_HOME:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#151);
+                  PTCKEY_END:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#159);
+                  PTCKEY_PAGEUP:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#153);
+                  PTCKEY_PAGEDOWN:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#161);
+                  PTCKEY_UP:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#152);
+                  PTCKEY_LEFT:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#155);
+                  PTCKEY_RIGHT:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#157);
+                  PTCKEY_DOWN:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#160);
+                  PTCKEY_DIVIDE:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#164);
+                  PTCKEY_MULTIPLY:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#55);
+                  PTCKEY_SUBTRACT:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#74);
+                  PTCKEY_ADD:
+                    if KeyMode in [kmGO32, kmFPWINCRT] then
+                      KeyBufAdd(#0#78);
                 end;
                 end;
               end
               end
               else
               else
@@ -197,7 +291,50 @@ begin
                     PTCKEY_F8:            KeyBufAdd(#0#101);
                     PTCKEY_F8:            KeyBufAdd(#0#101);
                     PTCKEY_F9:            KeyBufAdd(#0#102);
                     PTCKEY_F9:            KeyBufAdd(#0#102);
                     PTCKEY_F10:           KeyBufAdd(#0#103);
                     PTCKEY_F10:           KeyBufAdd(#0#103);
+                    PTCKEY_F11:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#137);
+                    PTCKEY_F12:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#138);
+                    PTCKEY_ONE:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#2);
                     PTCKEY_TWO:           KeyBufAdd(#0#3);
                     PTCKEY_TWO:           KeyBufAdd(#0#3);
+                    PTCKEY_THREE:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#4);
+                    PTCKEY_FOUR:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#5);
+                    PTCKEY_FIVE:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#6);
+                    PTCKEY_SIX:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#7)
+                      else
+                        KeyBufAdd(#30);
+                    PTCKEY_SEVEN:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#8);
+                    PTCKEY_EIGHT:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#9);
+                    PTCKEY_NINE:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#10);
+                    PTCKEY_ZERO:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#11);
+                    PTCKEY_MINUS:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#12)
+                      else
+                        KeyBufAdd(#31);
+                    PTCKEY_EQUALS:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#13);
                     PTCKEY_BACKSPACE:     KeyBufAdd(#127);
                     PTCKEY_BACKSPACE:     KeyBufAdd(#127);
                     PTCKEY_A:             KeyBufAdd(#1);
                     PTCKEY_A:             KeyBufAdd(#1);
                     PTCKEY_B:             KeyBufAdd(#2);
                     PTCKEY_B:             KeyBufAdd(#2);
@@ -228,8 +365,6 @@ begin
                     PTCKEY_OPENBRACKET:   KeyBufAdd(#27);
                     PTCKEY_OPENBRACKET:   KeyBufAdd(#27);
                     PTCKEY_BACKSLASH:     KeyBufAdd(#28);
                     PTCKEY_BACKSLASH:     KeyBufAdd(#28);
                     PTCKEY_CLOSEBRACKET:  KeyBufAdd(#29);
                     PTCKEY_CLOSEBRACKET:  KeyBufAdd(#29);
-                    PTCKEY_SIX:           KeyBufAdd(#30);
-                    PTCKEY_MINUS:         KeyBufAdd(#31);
                     PTCKEY_ENTER:         KeyBufAdd(#10);
                     PTCKEY_ENTER:         KeyBufAdd(#10);
                     PTCKEY_LEFT:          KeyBufAdd(#0#115);
                     PTCKEY_LEFT:          KeyBufAdd(#0#115);
                     PTCKEY_RIGHT:         KeyBufAdd(#0#116);
                     PTCKEY_RIGHT:         KeyBufAdd(#0#116);
@@ -237,6 +372,53 @@ begin
                     PTCKEY_END:           KeyBufAdd(#0#117);
                     PTCKEY_END:           KeyBufAdd(#0#117);
                     PTCKEY_PAGEUP:        KeyBufAdd(#0#132);
                     PTCKEY_PAGEUP:        KeyBufAdd(#0#132);
                     PTCKEY_PAGEDOWN:      KeyBufAdd(#0#118);
                     PTCKEY_PAGEDOWN:      KeyBufAdd(#0#118);
+                    PTCKEY_BACKQUOTE:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#41);
+                    PTCKEY_TAB:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#148);
+                    PTCKEY_SEMICOLON:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#39);
+                    PTCKEY_QUOTE:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#40);
+                    PTCKEY_COMMA:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#51);
+                    PTCKEY_PERIOD:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#52);
+                    PTCKEY_SLASH:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#149);
+                    PTCKEY_INSERT:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#146);
+                    PTCKEY_DELETE:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#147);
+                    PTCKEY_UP:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#141);
+                    PTCKEY_DOWN:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#145);
+                    PTCKEY_DIVIDE:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#149);
+                    PTCKEY_MULTIPLY:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#150);
+                    PTCKEY_SUBTRACT:
+                      if KeyMode in [kmGO32, kmFPWINCRT] then
+                        KeyBufAdd(#0#142);
+                    PTCKEY_ADD:
+                      if KeyMode = kmFPWINCRT then
+                        KeyBufAdd(#0#78)
+                      else if KeyMode = kmGO32 then
+                        KeyBufAdd(#0#144);
                   end;
                   end;
                 end
                 end
                 else
                 else
@@ -254,6 +436,12 @@ begin
                       PTCKEY_F8:        KeyBufAdd(#0#91);
                       PTCKEY_F8:        KeyBufAdd(#0#91);
                       PTCKEY_F9:        KeyBufAdd(#0#92);
                       PTCKEY_F9:        KeyBufAdd(#0#92);
                       PTCKEY_F10:       KeyBufAdd(#0#93);
                       PTCKEY_F10:       KeyBufAdd(#0#93);
+                      PTCKEY_F11:
+                        if KeyMode in [kmGO32, kmFPWINCRT] then
+                          KeyBufAdd(#0#135);
+                      PTCKEY_F12:
+                        if KeyMode in [kmGO32, kmFPWINCRT] then
+                          KeyBufAdd(#0#136);
                       PTCKEY_BACKSPACE: KeyBufAdd(#8);
                       PTCKEY_BACKSPACE: KeyBufAdd(#8);
                       PTCKEY_TAB:       KeyBufAdd(#0#15);
                       PTCKEY_TAB:       KeyBufAdd(#0#15);
                       PTCKEY_ENTER:     KeyBufAdd(#13);
                       PTCKEY_ENTER:     KeyBufAdd(#13);
@@ -286,6 +474,12 @@ begin
                       PTCKEY_F8:        KeyBufAdd(#0#66);
                       PTCKEY_F8:        KeyBufAdd(#0#66);
                       PTCKEY_F9:        KeyBufAdd(#0#67);
                       PTCKEY_F9:        KeyBufAdd(#0#67);
                       PTCKEY_F10:       KeyBufAdd(#0#68);
                       PTCKEY_F10:       KeyBufAdd(#0#68);
+                      PTCKEY_F11:
+                        if KeyMode in [kmGO32, kmFPWINCRT] then
+                          KeyBufAdd(#0#133);
+                      PTCKEY_F12:
+                        if KeyMode in [kmGO32, kmFPWINCRT] then
+                          KeyBufAdd(#0#134);
                       PTCKEY_BACKSPACE: KeyBufAdd(#8);
                       PTCKEY_BACKSPACE: KeyBufAdd(#8);
                       PTCKEY_TAB:       KeyBufAdd(#9);
                       PTCKEY_TAB:       KeyBufAdd(#9);
                       PTCKEY_ENTER:     KeyBufAdd(#13);
                       PTCKEY_ENTER:     KeyBufAdd(#13);

+ 20 - 4
packages/ptc/docs/CHANGES.txt

@@ -12,16 +12,18 @@
    then focusing back to it with a mouse click.
    then focusing back to it with a mouse click.
  - new key modifiers added for distinguishing between left and right shift,
  - new key modifiers added for distinguishing between left and right shift,
    control and alt, the status of num lock, caps lock and scroll lock and for
    control and alt, the status of num lock, caps lock and scroll lock and for
-   distinguishing numpad keys and dead keys. All of them are implemented as
-   elements in the ModifierKeys set, which was added to IPTCKeyEvent. They can
-   be checked, for example, with:
+   distinguishing right keys (e.g. right shift, right alt, right ctrl),
+   numpad keys and dead keys. All of them are implemented as elements in the
+   ModifierKeys set, which was added to IPTCKeyEvent. They can be checked,
+   for example, with:
      if pmkNumLockActive in key_event.ModifierKeys then
      if pmkNumLockActive in key_event.ModifierKeys then
        ...
        ...
    The following modifiers are available:
    The following modifiers are available:
      pmkAlt, pmkShift, pmkControl, pmkLeftAlt, pmkRightAlt, pmkLeftShift,
      pmkAlt, pmkShift, pmkControl, pmkLeftAlt, pmkRightAlt, pmkLeftShift,
      pmkRightShift, pmkLeftControl, pmkRightControl, pmkNumLockActive,
      pmkRightShift, pmkLeftControl, pmkRightControl, pmkNumLockActive,
      pmkNumLockPressed, pmkCapsLockActive, pmkCapsLockPressed,
      pmkNumLockPressed, pmkCapsLockActive, pmkCapsLockPressed,
-     pmkScrollLockActive, pmkScrollLockPressed, pmkNumPadKey, pmkDeadKey
+     pmkScrollLockActive, pmkScrollLockPressed, pmkRightKey, pmkNumPadKey,
+     pmkDeadKey
  - there is now a MoveMouseTo method, added to the console. It can be used to
  - there is now a MoveMouseTo method, added to the console. It can be used to
    warp the mouse cursor to a different location.
    warp the mouse cursor to a different location.
  - added support for a relative mouse mode. It supports continuous mouse
  - added support for a relative mouse mode. It supports continuous mouse
@@ -43,6 +45,20 @@
      PTCMouseButton9  - "forward" button ("X button 2")
      PTCMouseButton9  - "forward" button ("X button 2")
    The remaining mouse buttons are hardware specific and will vary, depending
    The remaining mouse buttons are hardware specific and will vary, depending
    on the actual mouse (provided it has that many buttons at all).
    on the actual mouse (provided it has that many buttons at all).
+ - ptccrt now supports several keyboard input modes, which can be set by
+   changing the new global variable KeyMode. The following values are supported:
+     kmTP7      - behaves like Turbo Pascal 7's CRT unit under DOS. This is the
+                  default value. Previous versions of ptccrt always behaved this
+                  way. Since TP7's CRT unit doesn't support the Enhanced
+                  Keyboard, several keys (e.g. F11 and F12) and key combinations
+                  are intentionally not recognized for compatibility reasons.
+     kmGO32     - behaves like Free Pascal's CRT unit under DOS (GO32V2). It has
+                  Enhanced Keyboard support.
+     kmFPWINCRT - behaves like Free Pascal's CRT unit under Windows. Similar to
+                  kmGO32, but emulates several incompatibilities that the
+                  Windows CRT unit has with the GO32V2 CRT unit. Not all of them
+                  are emulated though, since some of them can be considered
+                  bugs.
  - ptcgraph now has a global string variable WindowTitle, which allows you to
  - ptcgraph now has a global string variable WindowTitle, which allows you to
    set the window title, before calling InitGraph
    set the window title, before calling InitGraph
  - ptcgraph was extended to also support resolutions, different than the ones,
  - ptcgraph was extended to also support resolutions, different than the ones,

+ 1 - 1
packages/ptc/src/core/keyeventd.inc

@@ -36,7 +36,7 @@ type
     pmkNumLockActive, pmkNumLockPressed,
     pmkNumLockActive, pmkNumLockPressed,
     pmkCapsLockActive, pmkCapsLockPressed,
     pmkCapsLockActive, pmkCapsLockPressed,
     pmkScrollLockActive, pmkScrollLockPressed,
     pmkScrollLockActive, pmkScrollLockPressed,
-    pmkNumPadKey,pmkDeadKey);
+    pmkRightKey, pmkNumPadKey, pmkDeadKey);
   TPTCModifierKeys = set of TPTCModifierKey;
   TPTCModifierKeys = set of TPTCModifierKey;
   IPTCKeyEvent = interface(IPTCEvent)
   IPTCKeyEvent = interface(IPTCEvent)
     ['{9BD1CD41-1DF6-4392-99DC-885EADB6D85A}']
     ['{9BD1CD41-1DF6-4392-99DC-885EADB6D85A}']

+ 21 - 0
packages/ptc/src/win32/base/win32kbd.inc

@@ -82,8 +82,10 @@ var
   TranslatedCharacters, TranslatedWideCharacters: Integer;
   TranslatedCharacters, TranslatedWideCharacters: Integer;
   WideStr: WideString;
   WideStr: WideString;
   KeyCode: Integer;
   KeyCode: Integer;
+  ScanCodeB: Byte;
   ExtendedKey, DeadKey: Boolean;
   ExtendedKey, DeadKey: Boolean;
   ModifierKeys: TPTCModifierKeys;
   ModifierKeys: TPTCModifierKeys;
+  tmpUINT: UINT;
 begin
 begin
   Result := 0;
   Result := 0;
   { check enabled flag }
   { check enabled flag }
@@ -94,6 +96,7 @@ begin
   if (message = WM_KEYDOWN) or (message = WM_KEYUP) or (message = WM_SYSKEYDOWN) or (message = WM_SYSKEYUP) then
   if (message = WM_KEYDOWN) or (message = WM_KEYUP) or (message = WM_SYSKEYDOWN) or (message = WM_SYSKEYUP) then
   begin
   begin
     press := (message = WM_KEYDOWN) or (message = WM_SYSKEYDOWN);
     press := (message = WM_KEYDOWN) or (message = WM_SYSKEYDOWN);
+    ScanCodeB := Byte(lParam shr 16);
     ExtendedKey := (lParam and (1 shl 24)) <> 0;
     ExtendedKey := (lParam and (1 shl 24)) <> 0;
 
 
     ModifierKeys := [];
     ModifierKeys := [];
@@ -187,6 +190,24 @@ begin
       if ExtendedKey then
       if ExtendedKey then
         Include(ModifierKeys, pmkNumPadKey);
         Include(ModifierKeys, pmkNumPadKey);
     end;
     end;
+    if wParam = VK_SHIFT then
+    begin
+      tmpUINT := MapVirtualKey(ScanCodeB, MAPVK_VSC_TO_VK_EX);
+      if tmpUINT <> 0 then
+      begin
+        { Windows NT 4.0/2000+ }
+        if tmpUINT = VK_RSHIFT then
+          Include(ModifierKeys, pmkRightKey);
+      end
+      else
+      begin
+        { Windows 98 }
+        if ScanCodeB = 54 then
+          Include(ModifierKeys, pmkRightKey);
+      end;
+    end;
+    if ExtendedKey and (wParam in [VK_MENU,VK_CONTROL]) then
+      Include(ModifierKeys, pmkRightKey);
     if not ExtendedKey and
     if not ExtendedKey and
       (wParam in [VK_LEFT,VK_RIGHT,VK_UP,VK_DOWN,VK_INSERT,VK_DELETE,
       (wParam in [VK_LEFT,VK_RIGHT,VK_UP,VK_DOWN,VK_INSERT,VK_DELETE,
                   VK_HOME,VK_END,VK_PRIOR,VK_NEXT]) then
                   VK_HOME,VK_END,VK_PRIOR,VK_NEXT]) then

+ 6 - 0
packages/ptc/src/x11/x11displayi.inc

@@ -410,6 +410,7 @@ begin
   FNormalKeys[$FF and XK_semicolon] := Integer(PTCKEY_SEMICOLON);
   FNormalKeys[$FF and XK_semicolon] := Integer(PTCKEY_SEMICOLON);
   FNormalKeys[$FF and XK_equal] := Integer(PTCKEY_EQUALS);
   FNormalKeys[$FF and XK_equal] := Integer(PTCKEY_EQUALS);
   FNormalKeys[$FF and XK_grave] := Integer(PTCKEY_BACKQUOTE);
   FNormalKeys[$FF and XK_grave] := Integer(PTCKEY_BACKQUOTE);
+  FNormalKeys[$FF and XK_apostrophe] := Integer(PTCKEY_QUOTE);
 
 
   FNormalKeys[$FF and XK_bracketleft] := Integer(PTCKEY_OPENBRACKET);
   FNormalKeys[$FF and XK_bracketleft] := Integer(PTCKEY_OPENBRACKET);
   FNormalKeys[$FF and XK_backslash] := Integer(PTCKEY_BACKSLASH);
   FNormalKeys[$FF and XK_backslash] := Integer(PTCKEY_BACKSLASH);
@@ -492,6 +493,11 @@ begin
     press := False;
     press := False;
     uni := -1;
     uni := -1;
   end;
   end;
+  if (sym_modded = XK_Shift_R) or
+     (sym_modded = XK_Control_R) or
+     (sym_modded = XK_Meta_R) or
+     (sym_modded = XK_Alt_R) then
+    Include(modkeys, pmkRightKey);
   if (sym_modded = XK_KP_Insert) or
   if (sym_modded = XK_KP_Insert) or
      (sym_modded = XK_KP_Delete) or
      (sym_modded = XK_KP_Delete) or
      (sym_modded = XK_KP_Home) or
      (sym_modded = XK_KP_Home) or

+ 19 - 0
packages/ptc/tests/crtkeys/crtkeys.pas

@@ -0,0 +1,19 @@
+program crtkeys;
+uses
+  crt;
+var
+  Ch, Ex: Char;
+  Done: Boolean;
+begin
+  Done := False;
+  repeat
+    Ch := ReadKey;
+    if Ch = #0 then
+      Ex := ReadKey
+    else
+      Ex := #0;
+    Writeln(Ord(Ch), ' ', Ord(Ex));
+    if Ch = 'q' then
+      Done := True;
+  until Done;
+end.

+ 124 - 0
packages/ptc/tests/crtkeys/crtkeys_fpwincrt.txt

@@ -0,0 +1,124 @@
+Test results from the Win32 crt unit (from FPC 3.0.2), run under 32-bit Windows 7, US keyboard:
+
+Ctrl in the table means: Ctrl or Ctrl+Shift
+Alt in the table means: Alt or Alt+Shift or Alt+Ctrl or Alt+Ctrl+Shift
+
+key                |  -  |Shift|Ctrl |Alt  |NumLk|NumLk|NumLk|NumLk|
+                   |     |     |     |     |     |Shift|Ctrl |Alt  |
+-------------------+-----+-----+-----+-----+-----+-----+-----+-----+
+Esc                |27 0 |27 0 |*WIN*|*WIN*|27 0 |27 0 |*WIN*|*WIN*|
+F1                 |0 59 |0 84 |0 94 |0 104|0 59 |0 84 |0 94 |0 104|
+F2                 |0 60 |0 85 |0 95 |0 105|0 60 |0 85 |0 95 |0 105|
+F3                 |0 61 |0 86 |0 96 |0 106|0 61 |0 86 |0 96 |0 106|
+F4                 |0 62 |0 87 |0 97 |0 107|0 62 |0 87 |0 97 |0 107|
+F5                 |0 63 |0 88 |0 98 |0 108|0 63 |0 88 |0 98 |0 108|
+F6                 |0 64 |0 89 |0 99 |0 109|0 64 |0 89 |0 99 |0 109|
+F7                 |0 65 |0 90 |0 100|0 110|0 65 |0 90 |0 100|0 110|
+F8                 |0 66 |0 91 |0 101|0 111|0 66 |0 91 |0 101|0 111|
+F9                 |0 67 |0 92 |0 102|0 112|0 67 |0 92 |0 102|0 112|
+F10                |0 68 |0 93 |0 103|0 113|0 68 |0 93 |0 103|0 113|
+F11                |0 133|0 135|0 137|0 139|0 133|0 135|0 137|0 139|
+F12                |0 134|0 136|0 138|0 140|0 134|0 136|0 138|0 140|
+Print Screen/SysRq |     |     |     |     |     |     |     |     |
+Scroll Lock        |     |     |*BRK*|     |     |     |*BRK*|     |
+Pause/Break        |     |     |*BRK*|     |     |     |*BRK*|     |
+`                  |96 0 |126 0|0 41 |0 41 |96 0 |126 0|0 41 |0 41 |
+1                  |49 0 |33 0 |0 2  |0 120|49 0 |33 0 |0 2  |0 120|
+2                  |50 0 |64 0 |0 3  |0 121|50 0 |64 0 |0 3  |0 121|
+3                  |51 0 |35 0 |0 4  |0 122|51 0 |35 0 |0 4  |0 122|
+4                  |52 0 |36 0 |0 5  |0 123|52 0 |36 0 |0 5  |0 123|
+5                  |53 0 |37 0 |0 6  |0 124|53 0 |37 0 |0 6  |0 124|
+6                  |54 0 |94 0 |0 7  |0 125|54 0 |94 0 |0 7  |0 125|
+7                  |55 0 |38 0 |0 8  |0 126|55 0 |38 0 |0 8  |0 126|
+8                  |56 0 |42 0 |0 9  |0 127|56 0 |42 0 |0 9  |0 127|
+9                  |57 0 |40 0 |0 10 |0 128|57 0 |40 0 |0 10 |0 128|
+0                  |48 0 |41 0 |0 11 |0 129|48 0 |41 0 |0 11 |0 129|
+-                  |45 0 |95 0 |0 12 |0 130|45 0 |95 0 |0 12 |0 130|
+=                  |61 0 |43 0 |0 13 |0 131|61 0 |43 0 |0 13 |0 131|
+<- Backspace       |8 0  |8 0  |127 0|0 14 |8 0  |8 0  |127 0|0 14 |
+Tab                |9 0  |0 15 |0 148|*WIN*|9 0  |0 15 |0 148|*WIN*|
+q                  |113 0|81 0 |17 0 |0 16 |113 0|81 0 |17 0 |0 16 |
+w                  |119 0|87 0 |23 0 |0 17 |119 0|87 0 |23 0 |0 17 |
+e                  |101 0|69 0 |5 0  |0 18 |101 0|69 0 |5 0  |0 18 |
+r                  |114 0|82 0 |18 0 |0 19 |114 0|82 0 |18 0 |0 19 |
+t                  |116 0|84 0 |20 0 |0 20 |116 0|84 0 |20 0 |0 20 |
+y                  |121 0|89 0 |25 0 |0 21 |121 0|89 0 |25 0 |0 21 |
+u                  |117 0|85 0 |21 0 |0 22 |117 0|85 0 |21 0 |0 22 |
+i                  |105 0|73 0 |9 0  |0 23 |105 0|73 0 |9 0  |0 23 |
+o                  |111 0|79 0 |15 0 |0 24 |111 0|79 0 |15 0 |0 24 |
+p                  |112 0|80 0 |16 0 |0 25 |112 0|80 0 |16 0 |0 25 |
+[                  |91 0 |123 0|27 0 |0 26 |91 0 |123 0|27 0 |0 26 |
+]                  |93 0 |125 0|29 0 |0 27 |93 0 |125 0|29 0 |0 27 |
+\                  |92 0 |124 0|28 0 |0 43 |92 0 |124 0|28 0 |0 43 |
+Caps Lock          |     |     |     |     |     |     |     |     |
+a                  |97 0 |65 0 |1 0  |0 30 |97 0 |65 0 |1 0  |0 30 |
+s                  |115 0|83 0 |PAUSE|0 31 |115 0|83 0 |PAUSE|0 31 |
+d                  |100 0|68 0 |4 0  |0 32 |100 0|68 0 |4 0  |0 32 |
+f                  |102 0|70 0 |6 0  |0 33 |102 0|70 0 |6 0  |0 33 |
+g                  |103 0|71 0 |7 0  |0 34 |103 0|71 0 |7 0  |0 34 |
+h                  |104 0|72 0 |8 0  |0 35 |104 0|72 0 |8 0  |0 35 |
+j                  |106 0|74 0 |10 0 |0 36 |106 0|74 0 |10 0 |0 36 |
+k                  |107 0|75 0 |11 0 |0 37 |107 0|75 0 |11 0 |0 37 |
+l                  |108 0|76 0 |12 0 |0 38 |108 0|76 0 |12 0 |0 38 |
+;                  |59 0 |58 0 |0 39 |0 39 |59 0 |58 0 |0 39 |0 39 |
+'                  |39 0 |34 0 |0 40 |0 40 |39 0 |34 0 |0 40 |0 40 |
+Enter              |13 0 |13 0 |10 0 |*WIN*|13 0 |13 0 |10 0 |*WIN*|
+Left Shift         |     |     |     |     |     |     |     |     |
+z                  |122 0|90 0 |26 0 |0 44 |122 0|90 0 |26 0 |0 44 |
+x                  |120 0|88 0 |24 0 |0 45 |120 0|88 0 |24 0 |0 45 |
+c                  |99 0 |67 0 |*BRK*|0 46 |99 0 |67 0 |*BRK*|0 46 |
+v                  |118 0|86 0 |22 0 |0 47 |118 0|86 0 |22 0 |0 47 |
+b                  |98 0 |66 0 |2 0  |0 48 |98 0 |66 0 |2 0  |0 48 |
+n                  |110 0|78 0 |14 0 |0 49 |110 0|78 0 |14 0 |0 49 |
+m                  |109 0|77 0 |13 0 |0 50 |109 0|77 0 |13 0 |0 50 |
+,                  |44 0 |60 0 |0 51 |0 51 |44 0 |60 0 |0 51 |0 51 |
+.                  |46 0 |62 0 |0 52 |0 52 |46 0 |62 0 |0 52 |0 52 |
+/                  |47 0 |63 0 |0 149|0 164|47 0 |63 0 |0 149|0 164|
+Right Shift        |     |     |     |     |     |     |     |     |
+Left Ctrl          |     |     |     |     |     |     |     |     |
+Left Alt           |     |     |     |     |     |     |     |     |
+Space              |32 0 |32 0 |32 0 |*WIN*|32 0 |32 0 |32 0 |*WIN*|
+Right Alt          |     |     |     |     |     |     |     |     |
+Right Ctrl         |     |     |     |     |     |     |     |     |
+Insert             |0 82 |0 82 |0 146|NUMSC|0 82 |0 82 |0 146|NUMSC|
+Delete             |0 83 |0 83 |0 147|0 163|0 83 |0 83 |0 147|0 163|
+Home               |0 71 |0 71 |0 119|NUMSC|0 71 |0 71 |0 119|NUMSC|
+End                |0 79 |0 79 |0 117|NUMSC|0 79 |0 79 |0 117|NUMSC|
+Page Up            |0 73 |0 73 |0 132|NUMSC|0 73 |0 73 |0 132|NUMSC|
+Page Down          |0 81 |0 81 |0 118|NUMSC|0 81 |0 81 |0 118|NUMSC|
+Up Arrow           |0 72 |0 72 |0 141|NUMSC|0 72 |0 72 |0 141|NUMSC|
+Left Arrow         |0 75 |0 75 |0 115|NUMSC|0 75 |0 75 |0 115|NUMSC|
+Right Arrow        |0 77 |0 77 |0 116|NUMSC|0 77 |0 77 |0 116|NUMSC|
+Down Arrow         |0 80 |0 80 |0 145|NUMSC|0 80 |0 80 |0 145|NUMSC|
+Num Lock           |     |     |     |     |     |     |     |     |
+Num /              |0 53 |0 53 |0 149|0 164|0 53 |0 53 |0 149|0 164|
+Num *              |42 0 |42 0 |0 150|0 55 |42 0 |42 0 |0 150|0 55 |
+Num -              |45 0 |45 0 |0 142|0 74 |45 0 |45 0 |0 142|0 74 |
+Num +              |43 0 |43 0 |0 78 |0 78 |43 0 |43 0 |0 78 |0 78 |
+Num Enter          |13 0 |13 0 |10 0 |*WIN*|13 0 |13 0 |10 0 |*WIN*|
+Num 0/Ins          |0 82 |0 82 |0 146|NUMSC|48 0 |0 82 |0 146|NUMSC|
+Num ./Del          |0 83 |0 83 |0 147|0 163|46 0 |0 83 |0 147|0 163|
+Num 1/End          |0 79 |0 79 |0 117|NUMSC|49 0 |0 79 |0 117|NUMSC|
+Num 2/Down Arrow   |0 80 |0 80 |0 145|NUMSC|50 0 |0 80 |0 145|NUMSC|
+Num 3/PgDn         |0 81 |0 81 |0 118|NUMSC|51 0 |0 81 |0 118|NUMSC|
+Num 4/Left Arrow   |0 75 |0 75 |0 115|NUMSC|52 0 |0 75 |0 115|NUMSC|
+Num 5              |0 76 |0 76 |0 143|NUMSC|53 0 |0 76 |0 143|NUMSC|
+Num 6/Right Arrow  |0 77 |0 77 |0 116|NUMSC|54 0 |0 77 |0 116|NUMSC|
+Num 7/Home         |0 71 |0 71 |0 119|NUMSC|55 0 |0 71 |0 119|NUMSC|
+Num 8/Up Arrow     |0 72 |0 72 |0 141|NUMSC|56 0 |0 72 |0 141|NUMSC|
+Num 9/PgUp         |0 73 |0 73 |0 132|NUMSC|57 0 |0 73 |0 132|NUMSC|
+
+
+Special:
+  Ctrl+Shift+6: 30 0
+  Ctrl+Shift+-: 31 0
+  Ctrl+Shift+Backspace: 0 14
+  Ctrl+Shift+Space: 0 57
+  Alt+Ctrl+Space: 0 57
+  Alt+Ctrl+Shift+Space: 0 57
+  Alt+Ctrl+Enter: 0 166
+  Alt+Ctrl+Shift+Enter: 0 166
+
+*WIN* = Windows special key
+*BRK* = Ctrl+Break
+NUMSC = Numeric ASCII entry

+ 117 - 0
packages/ptc/tests/crtkeys/crtkeys_go32v2.txt

@@ -0,0 +1,117 @@
+Test results from the GO32V2 crt unit, run under DOS, on a PS/2 Model 76, 101-key US keyboard:
+
+Ctrl in the table means: Ctrl or Ctrl+Shift
+Alt in the table means: Alt or Alt+Shift or Alt+Ctrl or Alt+Ctrl+Shift
+
+key                |  -  |Shift|Ctrl |Alt  |NumLk|NumLk|NumLk|NumLk|
+                   |     |     |     |     |     |Shift|Ctrl |Alt  |
+-------------------+-----+-----+-----+-----+-----+-----+-----+-----+
+Esc                |27 0 |27 0 |27 0 |0 1  |27 0 |27 0 |27 0 |0 1  |
+F1                 |0 59 |0 84 |0 94 |0 104|0 59 |0 84 |0 94 |0 104|
+F2                 |0 60 |0 85 |0 95 |0 105|0 60 |0 85 |0 95 |0 105|
+F3                 |0 61 |0 86 |0 96 |0 106|0 61 |0 86 |0 96 |0 106|
+F4                 |0 62 |0 87 |0 97 |0 107|0 62 |0 87 |0 97 |0 107|
+F5                 |0 63 |0 88 |0 98 |0 108|0 63 |0 88 |0 98 |0 108|
+F6                 |0 64 |0 89 |0 99 |0 109|0 64 |0 89 |0 99 |0 109|
+F7                 |0 65 |0 90 |0 100|0 110|0 65 |0 90 |0 100|0 110|
+F8                 |0 66 |0 91 |0 101|0 111|0 66 |0 91 |0 101|0 111|
+F9                 |0 67 |0 92 |0 102|0 112|0 67 |0 92 |0 102|0 112|
+F10                |0 68 |0 93 |0 103|0 113|0 68 |0 93 |0 103|0 113|
+F11                |0 133|0 135|0 137|0 139|0 133|0 135|0 137|0 139|
+F12                |0 134|0 136|0 138|0 140|0 134|0 136|0 138|0 140|
+Print Screen/SysRq |     |     |0 114|     |     |     |0 114|     |
+Scroll Lock        |     |     |     |     |     |     |     |     |
+Pause/Break        |     |     |*BRK*|     |     |     |*BRK*|     |
+`                  |96 0 |126 0|     |0 41 |96 0 |126 0|     |0 41 |
+1                  |49 0 |33 0 |     |0 120|49 0 |33 0 |     |0 120|
+2                  |50 0 |64 0 |0 3  |0 121|50 0 |64 0 |0 3  |0 121|
+3                  |51 0 |35 0 |     |0 122|51 0 |35 0 |     |0 122|
+4                  |52 0 |36 0 |     |0 123|52 0 |36 0 |     |0 123|
+5                  |53 0 |37 0 |     |0 124|53 0 |37 0 |     |0 124|
+6                  |54 0 |94 0 |30 0 |0 125|54 0 |94 0 |30 0 |0 125|
+7                  |55 0 |38 0 |     |0 126|55 0 |38 0 |     |0 126|
+8                  |56 0 |42 0 |     |0 127|56 0 |42 0 |     |0 127|
+9                  |57 0 |40 0 |     |0 128|57 0 |40 0 |     |0 128|
+0                  |48 0 |41 0 |     |0 129|48 0 |41 0 |     |0 129|
+-                  |45 0 |95 0 |31 0 |0 130|45 0 |95 0 |31 0 |0 130|
+=                  |61 0 |43 0 |     |0 131|61 0 |43 0 |     |0 131|
+<- Backspace       |8 0  |8 0  |127 0|0 14 |8 0  |8 0  |127 0|0 14 |
+Tab                |9 0  |0 15 |0 148|0 165|9 0  |0 15 |0 148|0 165|
+q                  |113 0|81 0 |17 0 |0 16 |113 0|81 0 |17 0 |0 16 |
+w                  |119 0|87 0 |23 0 |0 17 |119 0|87 0 |23 0 |0 17 |
+e                  |101 0|69 0 |5 0  |0 18 |101 0|69 0 |5 0  |0 18 |
+r                  |114 0|82 0 |18 0 |0 19 |114 0|82 0 |18 0 |0 19 |
+t                  |116 0|84 0 |20 0 |0 20 |116 0|84 0 |20 0 |0 20 |
+y                  |121 0|89 0 |25 0 |0 21 |121 0|89 0 |25 0 |0 21 |
+u                  |117 0|85 0 |21 0 |0 22 |117 0|85 0 |21 0 |0 22 |
+i                  |105 0|73 0 |9 0  |0 23 |105 0|73 0 |9 0  |0 23 |
+o                  |111 0|79 0 |15 0 |0 24 |111 0|79 0 |15 0 |0 24 |
+p                  |112 0|80 0 |16 0 |0 25 |112 0|80 0 |16 0 |0 25 |
+[                  |91 0 |123 0|27 0 |0 26 |91 0 |123 0|27 0 |0 26 |
+]                  |93 0 |125 0|29 0 |0 27 |93 0 |125 0|29 0 |0 27 |
+\                  |92 0 |124 0|28 0 |0 43 |92 0 |124 0|28 0 |0 43 |
+Caps Lock          |     |     |     |     |     |     |     |     |
+a                  |97 0 |65 0 |1 0  |0 30 |97 0 |65 0 |1 0  |0 30 |
+s                  |115 0|83 0 |19 0 |0 31 |115 0|83 0 |19 0 |0 31 |
+d                  |100 0|68 0 |4 0  |0 32 |100 0|68 0 |4 0  |0 32 |
+f                  |102 0|70 0 |6 0  |0 33 |102 0|70 0 |6 0  |0 33 |
+g                  |103 0|71 0 |7 0  |0 34 |103 0|71 0 |7 0  |0 34 |
+h                  |104 0|72 0 |8 0  |0 35 |104 0|72 0 |8 0  |0 35 |
+j                  |106 0|74 0 |10 0 |0 36 |106 0|74 0 |10 0 |0 36 |
+k                  |107 0|75 0 |11 0 |0 37 |107 0|75 0 |11 0 |0 37 |
+l                  |108 0|76 0 |12 0 |0 38 |108 0|76 0 |12 0 |0 38 |
+;                  |59 0 |58 0 |     |0 39 |59 0 |58 0 |     |0 39 |
+'                  |39 0 |34 0 |     |0 40 |39 0 |34 0 |     |0 40 |
+Enter              |13 0 |13 0 |10 0 |0 28 |13 0 |13 0 |10 0 |0 28 |
+Left Shift         |     |     |     |     |     |     |     |     |
+z                  |122 0|90 0 |26 0 |0 44 |122 0|90 0 |26 0 |0 44 |
+x                  |120 0|88 0 |24 0 |0 45 |120 0|88 0 |24 0 |0 45 |
+c                  |99 0 |67 0 |3 0  |0 46 |99 0 |67 0 |3 0  |0 46 |
+v                  |118 0|86 0 |22 0 |0 47 |118 0|86 0 |22 0 |0 47 |
+b                  |98 0 |66 0 |2 0  |0 48 |98 0 |66 0 |2 0  |0 48 |
+n                  |110 0|78 0 |14 0 |0 49 |110 0|78 0 |14 0 |0 49 |
+m                  |109 0|77 0 |13 0 |0 50 |109 0|77 0 |13 0 |0 50 |
+,                  |44 0 |60 0 |     |0 51 |44 0 |60 0 |     |0 51 |
+.                  |46 0 |62 0 |     |0 52 |46 0 |62 0 |     |0 52 |
+/                  |47 0 |63 0 |     |0 53 |47 0 |63 0 |     |0 53 |
+Right Shift        |     |     |     |     |     |     |     |     |
+Left Ctrl          |     |     |     |     |     |     |     |     |
+Left Alt           |     |     |     |     |     |     |     |     |
+Space              |32 0 |32 0 |32 0 |32 0 |32 0 |32 0 |32 0 |32 0 |
+Right Alt          |     |     |     |     |     |     |     |     |
+Right Ctrl         |     |     |     |     |     |     |     |     |
+Insert             |0 82 |0 82 |0 146|0 162|0 82 |0 82 |0 146|0 162|
+Delete             |0 83 |0 83 |0 147|0 163|0 83 |0 83 |0 147|0 163|
+Home               |0 71 |0 71 |0 119|0 151|0 71 |0 71 |0 119|0 151|
+End                |0 79 |0 79 |0 117|0 159|0 79 |0 79 |0 117|0 159|
+Page Up            |0 73 |0 73 |0 132|0 153|0 73 |0 73 |0 132|0 153|
+Page Down          |0 81 |0 81 |0 118|0 161|0 81 |0 81 |0 118|0 161|
+Up Arrow           |0 72 |0 72 |0 141|0 152|0 72 |0 72 |0 141|0 152|
+Left Arrow         |0 75 |0 75 |0 115|0 155|0 75 |0 75 |0 115|0 155|
+Right Arrow        |0 77 |0 77 |0 116|0 157|0 77 |0 77 |0 116|0 157|
+Down Arrow         |0 80 |0 80 |0 145|0 160|0 80 |0 80 |0 145|0 160|
+Num Lock           |     |     |     |     |     |     |     |     |
+Num /              |47 0 |47 0 |0 149|0 164|47 0 |47 0 |0 149|0 164|
+Num *              |42 0 |42 0 |0 150|0 55 |42 0 |42 0 |0 150|0 55 |
+Num -              |45 0 |45 0 |0 142|0 74 |45 0 |45 0 |0 142|0 74 |
+Num +              |43 0 |43 0 |0 144|0 78 |43 0 |43 0 |0 144|0 78 |
+Num Enter          |13 0 |13 0 |10 0 |0 166|13 0 |13 0 |10 0 |0 166|
+Num 0/Ins          |0 82 |48 0 |0 146|NUMSC|48 0 |0 82 |0 146|NUMSC|
+Num ./Del          |0 83 |46 0 |0 147|     |46 0 |0 83 |0 147|     |
+Num 1/End          |0 79 |49 0 |0 117|NUMSC|49 0 |0 79 |0 117|NUMSC|
+Num 2/Down Arrow   |0 80 |50 0 |0 145|NUMSC|50 0 |0 80 |0 145|NUMSC|
+Num 3/PgDn         |0 81 |51 0 |0 118|NUMSC|51 0 |0 81 |0 118|NUMSC|
+Num 4/Left Arrow   |0 75 |52 0 |0 115|NUMSC|52 0 |0 75 |0 115|NUMSC|
+Num 5              |0 76 |53 0 |0 143|NUMSC|53 0 |0 76 |0 143|NUMSC|
+Num 6/Right Arrow  |0 77 |54 0 |0 116|NUMSC|54 0 |0 77 |0 116|NUMSC|
+Num 7/Home         |0 71 |55 0 |0 119|NUMSC|55 0 |0 71 |0 119|NUMSC|
+Num 8/Up Arrow     |0 72 |56 0 |0 141|NUMSC|56 0 |0 72 |0 141|NUMSC|
+Num 9/PgUp         |0 73 |57 0 |0 132|NUMSC|57 0 |0 73 |0 132|NUMSC|
+
+
+Special:
+  Ctrl+Alt+Caps or Ctrl+Alt+Shift+Caps: 0 64
+  Ctrl+Alt+Del or Ctrl+Alt+Shift+Del: reboot
+
+*BRK* = Ctrl+Break
+NUMSC = Numeric ASCII entry

+ 116 - 0
packages/ptc/tests/crtkeys/crtkeys_tp7.txt

@@ -0,0 +1,116 @@
+Test results from the Turbo Pascal 7 crt unit, run under DOS, on a PS/2 Model 76, 101-key US keyboard:
+
+Ctrl in the table means: Ctrl or Ctrl+Shift
+Alt in the table means: Alt or Alt+Shift or Alt+Ctrl or Alt+Ctrl+Shift
+
+key                |  -  |Shift|Ctrl |Alt  |NumLk|NumLk|NumLk|NumLk|
+                   |     |     |     |     |     |Shift|Ctrl |Alt  |
+-------------------+-----+-----+-----+-----+-----+-----+-----+-----+
+Esc                |27 0 |27 0 |27 0 |     |27 0 |27 0 |27 0 |     |
+F1                 |0 59 |0 84 |0 94 |0 104|0 59 |0 84 |0 94 |0 104|
+F2                 |0 60 |0 85 |0 95 |0 105|0 60 |0 85 |0 95 |0 105|
+F3                 |0 61 |0 86 |0 96 |0 106|0 61 |0 86 |0 96 |0 106|
+F4                 |0 62 |0 87 |0 97 |0 107|0 62 |0 87 |0 97 |0 107|
+F5                 |0 63 |0 88 |0 98 |0 108|0 63 |0 88 |0 98 |0 108|
+F6                 |0 64 |0 89 |0 99 |0 109|0 64 |0 89 |0 99 |0 109|
+F7                 |0 65 |0 90 |0 100|0 110|0 65 |0 90 |0 100|0 110|
+F8                 |0 66 |0 91 |0 101|0 111|0 66 |0 91 |0 101|0 111|
+F9                 |0 67 |0 92 |0 102|0 112|0 67 |0 92 |0 102|0 112|
+F10                |0 68 |0 93 |0 103|0 113|0 68 |0 93 |0 103|0 113|
+F11                |     |     |     |     |     |     |     |     |
+F12                |     |     |     |     |     |     |     |     |
+Print Screen/SysRq |     |     |0 114|     |     |     |0 114|     |
+Scroll Lock        |     |     |     |     |     |     |     |     |
+Pause/Break        |     |     |*BRK*|     |     |     |*BRK*|     |
+`                  |96 0 |126 0|     |     |96 0 |126 0|     |     |
+1                  |49 0 |33 0 |     |0 120|49 0 |33 0 |     |0 120|
+2                  |50 0 |64 0 |0 3  |0 121|50 0 |64 0 |0 3  |0 121|
+3                  |51 0 |35 0 |     |0 122|51 0 |35 0 |     |0 122|
+4                  |52 0 |36 0 |     |0 123|52 0 |36 0 |     |0 123|
+5                  |53 0 |37 0 |     |0 124|53 0 |37 0 |     |0 124|
+6                  |54 0 |94 0 |30 0 |0 125|54 0 |94 0 |30 0 |0 125|
+7                  |55 0 |38 0 |     |0 126|55 0 |38 0 |     |0 126|
+8                  |56 0 |42 0 |     |0 127|56 0 |42 0 |     |0 127|
+9                  |57 0 |40 0 |     |0 128|57 0 |40 0 |     |0 128|
+0                  |48 0 |41 0 |     |0 129|48 0 |41 0 |     |0 129|
+-                  |45 0 |95 0 |31 0 |0 130|45 0 |95 0 |31 0 |0 130|
+=                  |61 0 |43 0 |     |0 131|61 0 |43 0 |     |0 131|
+<- Backspace       |8 0  |8 0  |127 0|     |8 0  |8 0  |127 0|     |
+Tab                |9 0  |0 15 |     |     |9 0  |0 15 |     |     |
+q                  |113 0|81 0 |17 0 |0 16 |113 0|81 0 |17 0 |0 16 |
+w                  |119 0|87 0 |23 0 |0 17 |119 0|87 0 |23 0 |0 17 |
+e                  |101 0|69 0 |5 0  |0 18 |101 0|69 0 |5 0  |0 18 |
+r                  |114 0|82 0 |18 0 |0 19 |114 0|82 0 |18 0 |0 19 |
+t                  |116 0|84 0 |20 0 |0 20 |116 0|84 0 |20 0 |0 20 |
+y                  |121 0|89 0 |25 0 |0 21 |121 0|89 0 |25 0 |0 21 |
+u                  |117 0|85 0 |21 0 |0 22 |117 0|85 0 |21 0 |0 22 |
+i                  |105 0|73 0 |9 0  |0 23 |105 0|73 0 |9 0  |0 23 |
+o                  |111 0|79 0 |15 0 |0 24 |111 0|79 0 |15 0 |0 24 |
+p                  |112 0|80 0 |16 0 |0 25 |112 0|80 0 |16 0 |0 25 |
+[                  |91 0 |123 0|27 0 |     |91 0 |123 0|27 0 |     |
+]                  |93 0 |125 0|29 0 |     |93 0 |125 0|29 0 |     |
+\                  |92 0 |124 0|28 0 |     |92 0 |124 0|28 0 |     |
+Caps Lock          |     |     |     |     |     |     |     |     |
+a                  |97 0 |65 0 |1 0  |0 30 |97 0 |65 0 |1 0  |0 30 |
+s                  |115 0|83 0 |19 0 |0 31 |115 0|83 0 |19 0 |0 31 |
+d                  |100 0|68 0 |4 0  |0 32 |100 0|68 0 |4 0  |0 32 |
+f                  |102 0|70 0 |6 0  |0 33 |102 0|70 0 |6 0  |0 33 |
+g                  |103 0|71 0 |7 0  |0 34 |103 0|71 0 |7 0  |0 34 |
+h                  |104 0|72 0 |8 0  |0 35 |104 0|72 0 |8 0  |0 35 |
+j                  |106 0|74 0 |10 0 |0 36 |106 0|74 0 |10 0 |0 36 |
+k                  |107 0|75 0 |11 0 |0 37 |107 0|75 0 |11 0 |0 37 |
+l                  |108 0|76 0 |12 0 |0 38 |108 0|76 0 |12 0 |0 38 |
+;                  |59 0 |58 0 |     |     |59 0 |58 0 |     |     |
+'                  |39 0 |34 0 |     |     |39 0 |34 0 |     |     |
+Enter              |13 0 |13 0 |10 0 |     |13 0 |13 0 |10 0 |     |
+Left Shift         |     |     |     |     |     |     |     |     |
+z                  |122 0|90 0 |26 0 |0 44 |122 0|90 0 |26 0 |0 44 |
+x                  |120 0|88 0 |24 0 |0 45 |120 0|88 0 |24 0 |0 45 |
+c                  |99 0 |67 0 |3 0  |0 46 |99 0 |67 0 |3 0  |0 46 |
+v                  |118 0|86 0 |22 0 |0 47 |118 0|86 0 |22 0 |0 47 |
+b                  |98 0 |66 0 |2 0  |0 48 |98 0 |66 0 |2 0  |0 48 |
+n                  |110 0|78 0 |14 0 |0 49 |110 0|78 0 |14 0 |0 49 |
+m                  |109 0|77 0 |13 0 |0 50 |109 0|77 0 |13 0 |0 50 |
+,                  |44 0 |60 0 |     |     |44 0 |60 0 |     |     |
+.                  |46 0 |62 0 |     |     |46 0 |62 0 |     |     |
+/                  |47 0 |63 0 |     |     |47 0 |63 0 |     |     |
+Right Shift        |     |     |     |     |     |     |     |     |
+Left Ctrl          |     |     |     |     |     |     |     |     |
+Left Alt           |     |     |     |     |     |     |     |     |
+Space              |32 0 |32 0 |32 0 |32 0 |32 0 |32 0 |32 0 |32 0 |
+Right Alt          |     |     |     |     |     |     |     |     |
+Right Ctrl         |     |     |     |     |     |     |     |     |
+Insert             |0 82 |0 82 |     |     |0 82 |0 82 |     |     |
+Delete             |0 83 |0 83 |     |     |0 83 |0 83 |     |     |
+Home               |0 71 |0 71 |0 119|     |0 71 |0 71 |0 119|     |
+End                |0 79 |0 79 |0 117|     |0 79 |0 79 |0 117|     |
+Page Up            |0 73 |0 73 |0 132|     |0 73 |0 73 |0 132|     |
+Page Down          |0 81 |0 81 |0 118|     |0 81 |0 81 |0 118|     |
+Up Arrow           |0 72 |0 72 |     |     |0 72 |0 72 |     |     |
+Left Arrow         |0 75 |0 75 |0 115|     |0 75 |0 75 |0 115|     |
+Right Arrow        |0 77 |0 77 |0 116|     |0 77 |0 77 |0 116|     |
+Down Arrow         |0 80 |0 80 |     |     |0 80 |0 80 |     |     |
+Num Lock           |     |     |     |     |     |     |     |     |
+Num /              |47 0 |47 0 |     |     |47 0 |47 0 |     |     |
+Num *              |42 0 |42 0 |     |     |42 0 |42 0 |     |     |
+Num -              |45 0 |45 0 |     |     |45 0 |45 0 |     |     |
+Num +              |43 0 |43 0 |     |     |43 0 |43 0 |     |     |
+Num Enter          |13 0 |13 0 |10 0 |     |13 0 |13 0 |10 0 |     |
+Num 0/Ins          |0 82 |48 0 |     |NUMSC|48 0 |0 82 |     |NUMSC|
+Num ./Del          |0 83 |46 0 |     |     |46 0 |0 83 |     |     |
+Num 1/End          |0 79 |49 0 |0 117|NUMSC|49 0 |0 79 |0 117|NUMSC|
+Num 2/Down Arrow   |0 80 |50 0 |     |NUMSC|50 0 |0 80 |     |NUMSC|
+Num 3/PgDn         |0 81 |51 0 |0 118|NUMSC|51 0 |0 81 |0 118|NUMSC|
+Num 4/Left Arrow   |0 75 |52 0 |0 115|NUMSC|52 0 |0 75 |0 115|NUMSC|
+Num 5              |     |53 0 |     |NUMSC|53 0 |     |     |NUMSC|
+Num 6/Right Arrow  |0 77 |54 0 |0 116|NUMSC|54 0 |0 77 |0 116|NUMSC|
+Num 7/Home         |0 71 |55 0 |0 119|NUMSC|55 0 |0 71 |0 119|NUMSC|
+Num 8/Up Arrow     |0 72 |56 0 |     |NUMSC|56 0 |0 72 |     |NUMSC|
+Num 9/PgUp         |0 73 |57 0 |0 132|NUMSC|57 0 |0 73 |0 132|NUMSC|
+
+
+Special:
+  Ctrl+Alt+Del or Ctrl+Alt+Shift+Del: reboot
+
+*BRK* = Ctrl+Break
+NUMSC = Numeric ASCII entry

+ 33 - 0
packages/ptc/tests/crtkeys/ptccrtkeys.pas

@@ -0,0 +1,33 @@
+program ptccrtkeys;
+uses
+  ptccrt, ptcgraph;
+var
+  Gd, Gm: Integer;
+  Ch, Ex: Char;
+  Done: Boolean;
+begin
+  Gd := VGA;
+  Gm := VGAHi;
+  InitGraph(Gd, Gm, '');
+  Writeln('startup KeyMode (press ''m'' to switch): ', KeyMode);
+  Done := False;
+  repeat
+    Ch := ReadKey;
+    if Ch = #0 then
+      Ex := ReadKey
+    else
+      Ex := #0;
+    Writeln(Ord(Ch), ' ', Ord(Ex));
+    if Ch = 'm' then
+    begin
+      if KeyMode <> High(KeyMode) then
+        KeyMode := Succ(KeyMode)
+      else
+        KeyMode := Low(KeyMode);
+      Writeln('KeyMode: ', KeyMode);
+    end;
+    if Ch = 'q' then
+      Done := True;
+  until Done;
+  CloseGraph;
+end.