Module: SFML::Keyboard
- Defined in:
- ext/window/keyboard.c,
ext/window/keyboard.c
Overview
Real-time keyboard state and key/scancode lookups.
Class Method Summary collapse
-
.delocalize(key) ⇒ Integer
Returns the scancode that produces
keyon the current keyboard layout. -
.description(scancode) ⇒ String
Returns a human-readable, localized name for
scancode. -
.localize(scancode) ⇒ Symbol
Returns the key Symbol that
scancodeproduces on the current layout. -
.pressed?(key) ⇒ Boolean
keymay be a key Symbol (e.g.:a,:Enter,:LShift), a String key name, or an Integer key code. -
.scancode_pressed?(scancode) ⇒ Boolean
Unlike #pressed?,
scancodeidentifies a physical key position rather than the character it currently produces. -
.virtual_keyboard_visible=(value) ⇒ Boolean
Shows or hides the on-screen keyboard, where the platform provides one.
Class Method Details
.delocalize(key) ⇒ Integer
Returns the scancode that produces key on the current keyboard layout.
217 218 219 |
# File 'ext/window/keyboard.c', line 217
static VALUE Keyboard_delocalize(VALUE module, VALUE rb_key) {
return INT2NUM(sfKeyboard_delocalize((sfKeyCode)Keyboard_key_code(rb_key)));
}
|
.description(scancode) ⇒ String
Returns a human-readable, localized name for scancode.
228 229 230 231 232 |
# File 'ext/window/keyboard.c', line 228
static VALUE Keyboard_description(VALUE module, VALUE rb_scancode) {
const char* description = sfKeyboard_getDescription((sfScancode)NUM2INT(rb_scancode));
return rb_str_new_cstr(description != NULL ? description : "");
}
|
.localize(scancode) ⇒ Symbol
Returns the key Symbol that scancode produces on the current layout.
203 204 205 206 |
# File 'ext/window/keyboard.c', line 203
static VALUE Keyboard_localize(VALUE module, VALUE rb_scancode) {
return ID2SYM(rb_intern(
get_key_event((unsigned int)sfKeyboard_localize((sfScancode)NUM2INT(rb_scancode)))));
}
|
.pressed?(key) ⇒ Boolean
key may be a key Symbol (e.g. :a, :Enter, :LShift), a String key
name, or an Integer key code.
179 180 181 |
# File 'ext/window/keyboard.c', line 179
static VALUE Keyboard_pressed_p(VALUE module, VALUE rb_key) {
return BOOL2RB(sfKeyboard_isKeyPressed((sfKeyCode)Keyboard_key_code(rb_key)));
}
|
.scancode_pressed?(scancode) ⇒ Boolean
Unlike #pressed?, scancode identifies a physical key position rather
than the character it currently produces.
191 192 193 |
# File 'ext/window/keyboard.c', line 191
static VALUE Keyboard_scancode_pressed_p(VALUE module, VALUE rb_scancode) {
return BOOL2RB(sfKeyboard_isScancodePressed((sfScancode)NUM2INT(rb_scancode)));
}
|
.virtual_keyboard_visible=(value) ⇒ Boolean
Shows or hides the on-screen keyboard, where the platform provides one.
241 242 243 244 |
# File 'ext/window/keyboard.c', line 241
static VALUE Keyboard_set_virtual_keyboard_visible(VALUE module, VALUE rb_visible) {
sfKeyboard_setVirtualKeyboardVisible(RTEST(rb_visible));
return rb_visible;
}
|