Extracted from Pike v8.0 release 276 as of 2016-07-29.
   

Method SDL.get_key_state()


Method get_key_state

string get_key_state()

Description

Gets a snapshot of the current keyboard state.

Returns

The current state is returned as a string.

The string is indexed by the SDL.K_* symbols. A value of 1 means the key is pressed and a value of 0 means it's not.

Note

Call SDL.pump_events() to update the state array.

See also

SDL.get_mod_state(), SDL.pump_events()

Example

// Test if the 'Escape' key is pressed. SDL.pump_events(); string ks = SDL.get_key_state(); if ( ks[SDL.K_ESCAPE] ) { // handle key press...