Module for getting keyboard and mouse input. is* functions return info based on a us QWERTY layout. They are supposed to be used for game controls. For text input use getStr.

Keycode constants

const (
    mouse1*              = 1   // NOTE: mouse 2 and 3 key codes are swapped
    mouse2*              = 3   //       because sokol uses 3 for middle mouse
    mouse3*              = 2   //       button.

    key_ctrl*            = 16
    key_shift*           = 17
    key_alt*             = 18

    key_space*           = 32
    key_apostrophe*      = 39  /* ' */
    key_comma*           = 44  /* , */
    key_minus*           = 45  /* - */
    key_dot*             = 46  /* . */
    key_slash*           = 47  /* / */
    key_0*               = 48
    key_1*               = 49
    key_2*               = 50
    key_3*               = 51
    key_4*               = 52
    key_5*               = 53
    key_6*               = 54
    key_7*               = 55
    key_8*               = 56
    key_9*               = 57
    key_semicolon*       = 59  /* ; */
    key_equal*           = 61  /* = */
    key_a*               = 65
    key_b*               = 66
    key_c*               = 67
    key_d*               = 68
    key_e*               = 69
    key_f*               = 70
    key_g*               = 71
    key_h*               = 72
    key_i*               = 73
    key_j*               = 74
    key_k*               = 75
    key_l*               = 76
    key_m*               = 77
    key_n*               = 78
    key_o*               = 79
    key_p*               = 80
    key_q*               = 81
    key_r*               = 82
    key_s*               = 83
    key_t*               = 84
    key_u*               = 85
    key_v*               = 86
    key_w*               = 87
    key_x*               = 88
    key_y*               = 89
    key_z*               = 90
    key_left_bracket*    = 91  /* [ */
    key_backslash*       = 92  /* \ */
    key_right_bracket*   = 93  /* ] */
    key_grave_accent*    = 96  /* ` */
    key_world_1*         = 161 /* non-US #1 */
    key_world_2*         = 162 /* non-US #2 */
    key_escape*          = 256
    key_enter*           = 257
    key_tab*             = 258
    key_backspace*       = 259
    key_insert*          = 260
    key_delete*          = 261
    key_right*           = 262
    key_left*            = 263
    key_down*            = 264
    key_up*              = 265
    key_page_up*         = 266
    key_page_down*       = 267
    key_home*            = 268
    key_end*             = 269
    key_caps_lock*       = 280
    key_scroll_lock*     = 281
    key_num_lock*        = 282
    key_print_screen*    = 283
    key_pause*           = 284
	key_fn*              = 289
    key_fn1*             = 290
    key_fn2*             = 291
    key_fn3*             = 292
    key_fn4*             = 293
    key_fn5*             = 294
    key_fn6*             = 295
    key_fn7*             = 296
    key_fn8*             = 297
    key_fn9*             = 298
    key_fn10*            = 299
    key_fn11*            = 300
    key_fn12*            = 301
    key_fn13*            = 302
    key_fn14*            = 303
    key_fn15*            = 304
    key_fn16*            = 305
    key_fn17*            = 306
    key_fn18*            = 307
    key_fn19*            = 308
    key_fn20*            = 309
    key_fn21*            = 310
    key_fn22*            = 311
    key_fn23*            = 312
    key_fn24*            = 313
    key_fn25*            = 314
    key_kp_0*            = 320
    key_kp_1*            = 321
    key_kp_2*            = 322
    key_kp_3*            = 323
    key_kp_4*            = 324
    key_kp_5*            = 325
    key_kp_6*            = 326
    key_kp_7*            = 327
    key_kp_8*            = 328
    key_kp_9*            = 329
    key_kp_decimal*      = 330
    key_kp_divide*       = 331
    key_kp_multiply*     = 332
    key_kp_subtract*     = 333
    key_kp_add*          = 334
    key_kp_enter*        = 335
    key_kp_equal*        = 336
    key_left_shift*      = 340
    key_left_control*    = 341
    key_left_alt*        = 342
    key_left_super*      = 343
    key_right_shift*     = 344
    key_right_control*   = 345
    key_right_alt*       = 346
    key_right_super*     = 347
    key_menu*            = 348
)

fn getMousePos

fn getMousePos*(): th.Vf2 {

Returns the position of mouse cursor in relation to the screen.

fn getGlobalMousePos

fn getGlobalMousePos*(): th.Vf2 {

Returns the position of mouse cursor in relation to cam.

fn isPressed

fn isPressed*(code: int): bool {

Returns true if key is pressed. Either use codes defined in the file above, or pass lower case char/number.

fn isPressedc

fn isPressedc*(code: char): bool {

Like isPressed, but you can pass char as the code.

fn isJustPressed

fn isJustPressed*(code: int): bool {

Returns, whether code was just pressed this loop.

fn isJustPressedc

fn isJustPressedc*(code: char): bool {

Like isJustPressed, but you can pass char as the code.

fn isPressedRepeat

fn isPressedRepeat*(code: int): bool {

Returns, whether code was just pressed this loop, with key repeat.

fn isPressedRepeatc

fn isPressedRepeatc*(code: char): bool {

Like isPressedRepeat, but you can pass char as the code.

fn isJustReleased

fn isJustReleased*(code: int): bool {

Returns true if a key was just released.

fn isJustReleasedc

fn isJustReleasedc*(code: char): bool {

Like isJustReleased, but you can pass char as the code.

fn clear

fn clear*(code: int) {

Clears both the pressed and justPressed state of a code.

fn clearc

fn clearc*(code: char) {

Like clear, but you can pass char as the code.

fn getStr

fn getStr*(): str {

Returns a string entered by the user in the last cycle.

fn getMouseDelta

fn getMouseDelta*(): th.Vf2 {

Returns the difference between mouse positions in the last cycle. Will work even if window.freezeCursor is enabled.

fn getMouseScroll

fn getMouseScroll*(): th.Vf2 {

Returns the scroll wheel value