Announcement

Collapse
No announcement yet.

CHR$ Key Codes for F-11 and F-12

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • CHR$ Key Codes for F-11 and F-12

    I am aware that F-Keys 1 thru F-10 have the corresponding CHR$ code of (0,59) thru (0,68). However, I am unable to determine or locate the CHR$ codes (if any) for Keys F-11 and F-12. Could someone please post up a simple chart for these keys, as well as codes for the cursor keys (up, down, left, right, home, pg up, pg dn, end).

    Courtesy FYI -- I'm currently using PBCC 5.05

  • #2
    Here's one place ...

    Comment


    • #3
      CHR$(13) 'Enter
      CHR$(27) 'Esc
      CHR$(0,72) 'AUp
      CHR$(0,71) 'Home
      CHR$(0,80) 'ADown
      CHR$(0,73) 'PUp
      CHR$(0,81) 'PDown
      CHR$(0,77) 'ARight
      CHR$(0,75) 'ALeft
      CHR$(0,79) 'End
      CHR$(0,59) 'F1
      CHR$(0,60) 'F2
      CHR$(0,61) 'F3
      CHR$(0,62) 'F4
      CHR$(0,63) 'F5
      CHR$(0,64) 'F6
      CHR$(0,65) 'F7
      CHR$(0,66) 'F8
      CHR$(0,67) 'F9
      CHR$(0,68) 'F10
      CHR$(0,87) 'F11
      CHR$(0,88) 'F12

      Comment


      • #4

        Originally posted by Gary Beene View Post
        Here's one place ...
        Thank you both --

        I've also discovered INSERT (0,82) and DELETE (0,83).

        and was already familiar with ESCAPE (27) and RETURN (13).

        Now all I need is the code for BACKSPACE.

        Comment


        • #5
          Backspace is 8?
          Dale

          Comment


          • #6
            You can find a list of the key codes in win32api.inc - Look for %VK_F11 etc

            Here's a test console app to display key codes as typed.

            Code:
            #Compile Exe       ' PBCC505, 6
            #Dim All
            #Break On
            #Include "win32api.inc"
            '------------------/
            
            Function ControlCode(sKey As String) As String
             Function = Read$(Asc(sKey))
            
             Data 01 SOH ^A, 02 STX ^B, 03 ETX ^C, 04 EOT ^D, 05 ENQ ^E, 06 ACK ^F, 07 BEL ^G, 08 BS ^H, 09 HT ^I
             Data 10 LF ^J, 11 VT ^K, 12 FF ^L, 13 CR ^M, 14 SO ^N, 15 SI ^O, 16 DLE ^P, 17 DC1 ^Q, 18 DC2 ^R
             Data 19 DC3 ^S, 20 DC4 ^T, 21 NAK ^U, 22 SYN ^V, 23 ETB ^W, 24 CAN ^X, 25 EM ^Y, 26 SUB ^Z
             Data 27 ESC ^[, 28 FS ^\, 29 GS ^], 30 RS ^^, 31 US ^_
            End Function
            '------------------/ControlCode
            
            Function PBMain () As Long
             Local sKey, sTemp As String
             Local Vshift, Vcontrol, Htab As Integer
            
              Do While ConsHndl <> 0                            ' Exit loop when console closes
               sKey = InKey$
                Select Case Len(sKey)
                  Case 0                                        ' No (other) keys pressed
                    Sleep 1                                     ' RQD prior to Ver. 10/60 - still useful
                    If GetForeGroundWindow() = ConsHndl Then       ' only when this window has keyboard input
                      Htab = GetAsyncKeyState(%VK_TAB) And &H8000  ' Trap TAB key
                      If Htab Then                              ' has been pressed since last check
                        WinBeep 800,100
                        sTemp = ControlCode($Tab)
                        Console Name "Control Code: " + sTemp
                      End If
                    End If
            
                  Case 1                                        ' ASCII Key pressed
                    Locate 5,1 : Print sKey
                    Console Name " " + sKey + " =" + Str$(Asc(sKey)) + ", &H" + Hex$(Asc(Right$(sKey,1)))
                    If Asc(sKey) => 1 And Asc(sKey) =< 31 Then  ' Control Code
                      sTemp = ControlCode(sKey)
                      Console Name "Control Code: " + sTemp
                    End If
                    If sKey = $Spc Then
                      Console Name " <space> =" + Str$(Asc(sKey)) + ", &H" + Hex$(Asc(Right$(sKey,1)))
                    End If
                    sKey = ""
            
                  Case 2                                        ' Extended key pressed.
                    WinBeep 800,100
                    Vshift% = GetAsyncKeyState(%VK_SHIFT)
                    Vcontrol% = GetAsyncKeyState(%VK_CONTROL)
            
                    Select Case Asc(sKey,2)
                     sTemp += IIf$((Vshift And &H8000), "Shift-","") + IIf$((Vcontrol And &H8000), "Control-","")
                      Case 59 : sTemp += "F1"
                      Case 60 : sTemp += "F2"
                      Case 61 : sTemp += "F3"
                      Case 62 : sTemp += "F4"
                      Case 63 : sTemp += "F5"
                      Case 64 : sTemp += "F6"
                      Case 65 : sTemp += "F7"
                      Case 66 : sTemp += "F8"
                      Case 67 : sTemp += "F9"
                      Case 68 : sTemp += "F10"              ' (Comments for Graphic Inkey$)
                      Case 87 : sTemp += "F11"              ' Since Ver. 903/503
                      Case 88 : sTemp += "F12"              ' Since Ver. 903/503   ?
                      Case 69 : sTemp += "NumLock"
                      Case 71 : sTemp += "Home"             ' * NB  These keys not detected on number pad
                      Case 72 : sTemp += "Up Arrow"         '       prior to Ver. 904/504*
                      Case 73 : sTemp += "Page up"          '
                      Case 75 : sTemp += "Left arrow"       '
                      Case 77 : sTemp += "Right arrow"      '
                      Case 79 : sTemp += "End"              '
                      Case 80 : sTemp += "Down arrow"       '
                      Case 81 : sTemp += "Page down"        '
                      Case 82 : sTemp += "Insert"           '
                      Case 83 : sTemp += "Delete"           '
                      Case 91, 92 : sTemp = "WindowsKey"
                      Case Else : sTemp = "Other:" + Str$(Asc(sKey,2))
                    End Select
                    Console Name " " + sTemp + " =" + Str$(Asc(sKey,2)) + ", &h" + Hex$(Asc(sKey,2))
                End Select
                sTemp = ""
              Loop
            
             StdOut sTemp + $CrLf + "Done"
            #If %Def(%PB_CC32)
              ? "Any key to exit"
              WaitKey$
             #EndIf
            End Function
            '------------------/PBMain


            Rgds, Dave

            Comment


            • #7
              Originally posted by Frank Ferrell View Post


              Thank you both --

              I've also discovered INSERT (0,82) and DELETE (0,83).

              and was already familiar with ESCAPE (27) and RETURN (13).

              Now all I need is the code for BACKSPACE.
              You can write a small app that will take keyboard input and display the numeric codes given.
              The world is strange and wonderful.*
              I reserve the right to be horrifically wrong.
              Please maintain a safe following distance.
              *wonderful sold separately.

              Comment


              • #8
                You can also try the code in post#2 of this thread:
                https://forum.powerbasic.com/forum/a...tement?t=56151
                Rod
                "To every unsung hero in the universe
                To those who roam the skies and those who roam the earth
                To all good men of reason may they never thirst " - from "Heaven Help the Devil" by G. Lightfoot

                Comment


                • #9
                  Here is a silly simple program that I wrote 14 years ago

                  Code:
                  FUNCTION PBMAIN
                  DIM a AS STRING
                  start:
                  MOUSE ON
                  MOUSE 3,DOUBLE,MOVE,UP,DOWN
                  a$ = WAITKEY$
                  CLS
                  PRINT "a$ ";
                  PRINT a$
                  PRINT "LEN(a$) ";
                  PRINT LEN(a$)
                  PRINT "ASC(MID$(a$,1,1)) ";
                  PRINT ASC(MID$(a$,1,1))
                  PRINT "ASC(MID$(a$,2,1)) ";
                  PRINT ASC(MID$(a$,2,1))
                  PRINT "ASC(MID$(a$,3,1)) ";
                  PRINT ASC(MID$(a$,3,1))
                  PRINT "ASC(MID$(a$,4,1)) ";
                  PRINT ASC(MID$(a$,4,1))
                  GOTO start
                  END FUNCTION
                  [I]I made a coding error once - but fortunately I fixed it before anyone noticed[/I]
                  Kerry Farmer

                  Comment


                  • #10
                    Originally posted by Kerry Farmer View Post
                    Here is a silly simple program that I wrote 14 years ago
                    Simply Great -- Thanks all responders --- I got all I needed from this thread.

                    Also -- I now know that the TAB key is CHR$(9)

                    Comment

                    Working...
                    X