rudl_keyboard

Back to index

# Index

Key
Class and instance Methods
`Key.focused?`
`Key#focused?`
`Key.modifiers`
`Key#modifiers`
`Key.pressed?`
`Key#pressed?`
`Key.name( key )`
`Key#name( key )`
`Key.modifiers=( modifiers )`
`Key#modifiers=( modifiers )`
`Key.set_repeat( delay, interval )`
`Key#set_repeat( delay, interval )`
Events
KeyUpEvent
`KeyUpEvent#key`
`KeyUpEvent#mod`
`KeyUpEvent#unicode`
KeyDownEvent
`KeyDownEvent#key`
`KeyDownEvent#mod`
`KeyDownEvent#unicode`
Constants

# Key

The Key class gives access to the keyboard without events.

You can either call the class methods: "Key.something" directly, or instantiate the class and lug along a reference to it and call instance methods on that: "k=Key.new" "k.something" (they will call class methods under the hood, so it's exactly the same)

EventQueue.pump will update the state of Key, so if no keys seem to be pressed, call pump.

## Class and instance Methods

`Key.focused?`
`Key#focused?`

Returns true when the application has the keyboard input focus.

`Key.modifiers`
`Key#modifiers`

Returns the current modifier keys state.

`Key.pressed?`
`Key#pressed?`

Returns a hash containing all keys that are set, set to true. So, if K_b is pressed, the hash will contain a key,value pair of K_b => true.

`Key.name( key )`
`Key#name( key )`

Returns a string describing constant key

`Key.modifiers=( modifiers )`
`Key#modifiers=( modifiers )`

Sets the keyboard modifier state.

`Key.set_repeat( delay, interval )`
`Key#set_repeat( delay, interval )`

Sets the keyboard to wait for delay milliseconds before starting repeat with interval delay between repeats. Set both to zero to disable repeat.

# Events

## KeyUpEvent

This event is posted when a key is released.

`KeyUpEvent#key`

The keycode for the released key.

`KeyUpEvent#mod`

The modifier keys state.

`KeyUpEvent#unicode`

The Unicode version of the key.

## KeyDownEvent

This event is posted when a key is pressed and when it gets repeated (see Key#set_repeat).

`KeyDownEvent#key`

The keycode for the pressed key.

`KeyDownEvent#mod`

The modifier keys state.

`KeyDownEvent#unicode`

The Unicode version of the key.

# Constants

Keycodes in one handy big mess:

K_UNKNOWN, K_FIRST, K_BACKSPACE, K_TAB, K_CLEAR, K_RETURN, K_PAUSE, K_ESCAPE, K_SPACE, K_EXCLAIM, K_QUOTEDBL, K_HASH, K_DOLLAR, K_AMPERSAND, K_QUOTE, K_LEFTPAREN, K_RIGHTPAREN, K_ASTERISK, K_PLUS, K_COMMA, K_MINUS, K_PERIOD, K_SLASH, K_0, K_1, K_2, K_3, K_4, K_5, K_6, K_7, K_8, K_9, K_COLON, K_SEMICOLON, K_LESS, K_EQUALS, K_GREATER, K_QUESTION, K_AT, K_LEFTBRACKET, K_BACKSLASH, K_RIGHTBRACKET, K_CARET, K_UNDERSCORE, K_BACKQUOTE, K_a, K_b, K_c, K_d, K_e, K_f, K_g, K_h, K_i, K_j, K_k, K_l, K_m, K_n, K_o, K_p, K_q, K_r, K_s, K_t, K_u, K_v, K_w, K_x, K_y, K_z, K_DELETE, K_KP0, K_KP1, K_KP2, K_KP3, K_KP4, K_KP5, K_KP6, K_KP7, K_KP8, K_KP9, K_KP_PERIOD, K_KP_DIVIDE, K_KP_MULTIPLY, K_KP_MINUS, K_KP_PLUS, K_KP_ENTER, K_KP_EQUALS, K_UP, K_DOWN, K_RIGHT, K_LEFT, K_INSERT, K_HOME, K_END, K_PAGEUP, K_PAGEDOWN, K_F1, K_F2, K_F3, K_F4, K_F5, K_F6, K_F7, K_F8, K_F9, K_F10, K_F11, K_F12, K_F13, K_F14, K_F15, , K_NUMLOCK, K_CAPSLOCK, K_SCROLLOCK, K_RSHIFT, K_LSHIFT, K_RCTRL, K_LCTRL, K_RALT, K_LALT, K_RMETA, K_LMETA, K_LSUPER, K_RSUPER, K_MODE, K_HELP, K_PRINT, K_SYSREQ, K_BREAK, K_MENU, K_POWER, K_EURO, K_LAST, KMOD_NONE, KMOD_LSHIFT, KMOD_RSHIFT, KMOD_LCTRL, KMOD_RCTRL, KMOD_LALT, KMOD_RALT, KMOD_LMETA, KMOD_RMETA, KMOD_NUM, KMOD_CAPS, KMOD_MODE, KMOD_CTRL, KMOD_SHIFT, KMOD_ALT, KMOD_META

Back to index