Skip to content

input.um

Marek Maskarinec edited this page Sep 14, 2022 · 2 revisions

input.um

 Module for getting keyboard and mouse input.
 Keycodes are ascii chars (lower case) and the constants below.
   mouse1
   mouse2
   mouse3
   key_shift
   key_backspace
   key_delete
   key_left
   key_right
   key_up
   key_down
   key_escape
   key_enter
 
 is* functions return info based on a us QWERTY layout. They are supposed to
 be used for game controls. For text input use getStr.

fn getMousePos*

fn getMousePos*(): th.Vf2 {

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

fn getGlobalMousePos*

fn getGlobalMousePos*(cam: rect.Rect): th.Vf2 {

Returns the position of mouse cursor in relation to cam.

fn isPressed*

fn isPressed*(code: char): bool {

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

fn isJustPressed*

fn isJustPressed*(code: char): bool {

Returns, whether code was just pressed this loop.

fn isJustReleased*

fn isJustReleased*(code: char): bool {

Returns true if a key was just released.

fn cclear*

fn cclear*(code: char)

fn clear*

fn clear*(code: char) {

Clears both the pressed and justPressed state of a code.

fn getStr*

fn getStr*(): str {

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

Clone this wiki locally