Module: SDL2::Key::Mod

Defined in:
key.c,
key.c

Overview

This module has key modifier bitmask constants and some functions to handle key modifier states.

Constant Summary collapse

NONE =

Returns 0 (no modifier is applicable).

Returns:

  • (Integer)

    0 (no modifier is applicable)

INT2NUM(KMOD_NONE)
LSHIFT =

Returns the modifier key bit mask for the left shift key.

Returns:

  • (Integer)

    the modifier key bit mask for the left shift key

INT2NUM(KMOD_LSHIFT)
RSHIFT =

Returns the modifier key bit mask for the right shift key.

Returns:

  • (Integer)

    the modifier key bit mask for the right shift key

INT2NUM(KMOD_RSHIFT)
LCTRL =

Returns the modifier key bit mask for the left control key.

Returns:

  • (Integer)

    the modifier key bit mask for the left control key

INT2NUM(KMOD_LCTRL)
RCTRL =

Returns the modifier key bit mask for the right control key.

Returns:

  • (Integer)

    the modifier key bit mask for the right control key

INT2NUM(KMOD_RCTRL)
LALT =

Returns the modifier key bit mask for the left alt key.

Returns:

  • (Integer)

    the modifier key bit mask for the left alt key

INT2NUM(KMOD_LALT)
RALT =

Returns the modifier key bit mask for the right alt key.

Returns:

  • (Integer)

    the modifier key bit mask for the right alt key

INT2NUM(KMOD_RALT)
LGUI =

Returns the modifier key bit mask for the left GUI key (often the window key).

Returns:

  • (Integer)

    the modifier key bit mask for the left GUI key (often the window key)

INT2NUM(KMOD_LGUI)
RGUI =

Returns the modifier key bit mask for the right GUI key (often the window key).

Returns:

  • (Integer)

    the modifier key bit mask for the right GUI key (often the window key)

INT2NUM(KMOD_RGUI)
NUM =

Returns the modifier key bit mask for the numlock key.

Returns:

  • (Integer)

    the modifier key bit mask for the numlock key

INT2NUM(KMOD_NUM)
CAPS =

Returns the modifier key bit mask for the capslock key.

Returns:

  • (Integer)

    the modifier key bit mask for the capslock key

INT2NUM(KMOD_CAPS)
MODE =

Returns the modifier key bit mask for the mode key (AltGr).

Returns:

  • (Integer)

    the modifier key bit mask for the mode key (AltGr)

INT2NUM(KMOD_MODE)
CTRL =

Returns the modifier key bit mask for the left and right control key.

Returns:

  • (Integer)

    the modifier key bit mask for the left and right control key

INT2NUM(KMOD_CTRL)
SHIFT =

Returns the modifier key bit mask for the left and right shift key.

Returns:

  • (Integer)

    the modifier key bit mask for the left and right shift key

INT2NUM(KMOD_SHIFT)
ALT =

Returns the modifier key bit mask for the left and right alt key.

Returns:

  • (Integer)

    the modifier key bit mask for the left and right alt key

INT2NUM(KMOD_ALT)
GUI =

Returns the modifier key bit mask for the left and right GUI key.

Returns:

  • (Integer)

    the modifier key bit mask for the left and right GUI key

INT2NUM(KMOD_GUI)
RESERVED =

Returns reserved bit mask for future use.

Returns:

  • (Integer)

    reserved bit mask for future use

INT2NUM(KMOD_RESERVED)

Class Method Summary collapse

Class Method Details

.stateInteger

Get the current key modifier state

You can examine whether the modifier key is pressed using bitmask constants of SDL2::Key::Mod.

Returns:

  • (Integer)

    key state



152
153
154
155
# File 'key.c', line 152

static VALUE Mod_s_state(VALUE self)
{
    return UINT2NUM(SDL_GetModState());
}

.state=(keymod) ⇒ void

Note:

This does not change the keyboard state, only the key modifier flags.

This method returns an undefined value.

Set the current key modifier state

Parameters:

  • keymod (Integer)

    key modifier flags (bits)

See Also:



167
168
169
170
171
# File 'key.c', line 167

static VALUE Mod_s_set_state(VALUE self, VALUE keymod)
{
    SDL_SetModState(NUM2UINT(keymod));
    return Qnil;
}