Counter-Strike 2

Counter-Strike 2

Not enough ratings
Scancode binds for dummies
By implied
This guide explains scancodes and helps you get up-to-speed for porting your autoexec binds to the new system.
   
Award
Favorite
Favorited
Unfavorite
Introduction to scancodes
What's a scancode?
Scancodes are a number assigned to a specific key. They're what your computer uses to say "oh, the user pressed this button, I should type this letter!" and are how your computer can different letters on the same keys.

Why do they matter for CS2?
CS2 recently updated a scancode based input system. Migrating your configuration will future-proof it and provide a neat added benefit.

How are scancodes different than normal key binds?
Scancodes are position-based, rather than input-based, so they behave the same across keyboard layouts.
List of scancodes
You cannot use just the numbers to bind! Use scancodeNUM, replacing NUM with the number for the key. Example:
// scancoded version of: bind w +forward bind scancode26 +forward
The following is an incomplete list of scancodes, e.g. covers most of an ANSI 80% keyboard:
  1. <unused at time of writing>
  2. <unused at time of writing>
  3. <unused at time of writing>
  4. a
  5. b
  6. c
  7. d
  8. e
  9. f
  10. g
  11. h
  12. i
  13. j
  14. k
  15. l
  16. m
  17. n
  18. o
  19. p
  20. q
  21. r
  22. s
  23. t
  24. u
  25. v
  26. w
  27. x
  28. y
  29. z
  30. 1
  31. 2
  32. 3
  33. 4
  34. 5
  35. 6
  36. 7
  37. 8
  38. 9
  39. 0
  40. enter/return
  41. escape
  42. backspace
  43. tab
  44. space
  45. -
  46. =
  47. [
  48. ]
  49. \
  50. # (NOT the same as shift-3!)
  51. ;
  52. '
  53. `
  54. ,
  55. .
  56. /
  57. caps lock
  58. F1
  59. F2
  60. F3
  61. F4
  62. F5
  63. F6
  64. F7
  65. F8
  66. F9
  67. F10
  68. F11
  69. F12
How to find scancodes
Via SDL2 mappings
This is untested and may be inaccurate.

CS2 scancodes appear to map 1-to-1 with SDL2. This means you can look up your key's scancode for any SDL2 title, such as with this table[wiki.libsdl.org], and get the scancode you want. For example:

// sdl2 table: Decimal Value Hexadecimal Value SDL_Scancode Constant 26 0x01A SDL_SCANCODE_W // cs2 version: bind scancode26 "+forward" // bind w "+foward"

Via legacy key names
Executing any bind command with an old-style keyboard button (see below) logs a scancode into the console. While this is layout-dependent when grabbing the scancode, it will map correctly if you switch layouts after the fact.

A commented example for a typical en-US layout:
// log current bind for key so you can reset it bind w // output: // [Console] bind [player 0]: "w" = "+forward" // console logs your layout's scancode value for w below when parsing this bind w "echo no-op" // output: // Interpreting bind command as: // bind scancode26 "echo no-op" // US English key name "w" // remember to rebind! bind w "+forward" // output: // Interpreting bind command as: // bind scancode26 "+forward" // US English key name "w"