Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Key_Scancodes Include
#1
Just posting this here for anyone that may want to use it. Hopefully it comes in handy. Smile

Code:
' Keyboard Scancodes - Use with GetKey
'

' Arrows
const keyUp = "72", keyDown = "80", keyLeft = "75", keyRight = "77"
' Position
const keyEnter = "13", keyBack = "8", keyDelete = "83", keyInsert = "82"
const keyHome = "71", keyEnd = "79", keyPageup = "73", keyPagedown = "81"
' Function
const keyF1 = "59", keyF2 = "60", keyF3 = "61", keyF4 = "62", keyF5 = "63"
const keyF6 = "64", keyF7 = "65", keyF8 = "66", keyF9 = "67", keyF10 = "68"
const keyF11 = "133", keyF12 = "134"
' Misc
const keyEsc = "27"

EDIT: Forgot one thing; all the above Consts are strings, and getkey returns an integer(?). So either remove the quotes from the consts or use str$(getkey) to get the correct comparison. Sorry for the troubles. :???:
Reply
#2
BigPapaN0z:
I agree with you keyboard scan codes should be predefined.
I recovered the complete list from the gfxlib source. Put it in a file called "scancodes.bi" in your freebasic\bi folder, then include in the top of your programs.

#include scancodes.bi
or if you prefer
'$include:'scancodes.bi'

v1ctor, lillo, Sterling:
Perhaps this file should be in the distribution..

Code:
'scancodes.bi'
#define SC_ESCAPE    &H01
#define SC_1        &H02
#define SC_2        &H03
#define SC_3        &H04
#define SC_4        &H05
#define SC_5        &H06
#define SC_6        &H07
#define SC_7        &H08
#define SC_8        &H09
#define SC_9        &H0A
#define SC_0        &H0B
#define SC_MINUS    &H0C
#define SC_EQUALS    &H0D
#define SC_BACKSPACE    &H0E
#define SC_TAB        &H0F
#define SC_Q        &H10
#define SC_W        &H11
#define SC_E        &H12
#define SC_R        &H13
#define SC_T        &H14
#define SC_Y        &H15
#define SC_U        &H16
#define SC_I        &H17
#define SC_O        &H18
#define SC_P        &H19
#define SC_LEFTBRACKET    &H1A
#define SC_RIGHTBRACKET    &H1B
#define SC_ENTER    &H1C
#define SC_CONTROL    &H1D
#define SC_A        &H1E
#define SC_S        &H1F
#define SC_D        &H20
#define SC_F        &H21
#define SC_G        &H22
#define SC_H        &H23
#define SC_J        &H24
#define SC_K        &H25
#define SC_L        &H26
#define SC_SEMICOLON    &H27
#define SC_QUOTE    &H28
#define SC_TILDE    &H29
#define SC_LSHIFT    &H2A
#define SC_BACKSLASH    &H2B
#define SC_Z        &H2C
#define SC_X        &H2D
#define SC_C        &H2E
#define SC_V        &H2F
#define SC_B        &H30
#define SC_N        &H31
#define SC_M        &H32
#define SC_COMMA    &H33
#define SC_PERIOD    &H34
#define SC_SLASH    &H35
#define SC_RSHIFT    &H36
#define SC_MULTIPLY    &H37
#define SC_ALT        &H38
#define SC_SPACE    &H39
#define SC_CAPSLOCK    &H3A
#define SC_F1        &H3B
#define SC_F2        &H3C
#define SC_F3        &H3D
#define SC_F4        &H3E
#define SC_F5        &H3F
#define SC_F6        &H40
#define SC_F7        &H41
#define SC_F8        &H42
#define SC_F9        &H43
#define SC_F10        &H44
#define SC_NUMLOCK    &H45
#define SC_SCROLLLOCK    &H46
#define SC_HOME        &H47
#define SC_UP        &H48
#define SC_PAGEUP    &H49
#define SC_LEFT        &H4B
#define SC_RIGHT    &H4D
#define SC_PLUS        &H4E
#define SC_END        &H4F
#define SC_DOWN        &H50
#define SC_PAGEDOWN    &H51
#define SC_INSERT    &H52
#define SC_DELETE    &H53
#define SC_F11        &H57
#define SC_F12        &H58

#define SC_LWIN        &H7D
#define SC_RWIN        &H7E
#define SC_MENU        &H7F

Wow, I ported a header for FB :king:
Antoni
Reply
#3
See Appendix A of docs/gfxlib.txt. Smile Lillo has recommended that you make a header containing the exact same definitions there.

Maybe there is a reason why there isn't a default 'scancodes.bi' in the FreeBASIC distribution (or maybe there will be in 0.12... Smile).

-shiftLynx
img]http://www.cdsoft.co.uk/misc/shiftlynx.png[/img]
Reply
#4
Someone stole my idea Big Grin
Antoni
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)