Module: AMS::Keyboard

Defined in:
Documentation/ams/keyboard.rb

Overview

Note:

Most methods for this module are Mac OS X compatible unless otherwise stated.

This namespace contains keyboard key state retrieval functions.

Since:

  • 2.0.0

Class Method Summary collapse

Class Method Details

.control_down?Boolean Also known as: ctrl_down?

Determine whether CTRL key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


119
120
# File 'Documentation/ams/keyboard.rb', line 119

def control_down?
end

.control_up?Boolean Also known as: ctrl_up?

Determine whether CTRL key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


126
127
# File 'Documentation/ams/keyboard.rb', line 126

def control_up?
end

.get_key_code(vk_name) ⇒ Fixnum?

Get virtual key code associated with the virtual key name.

Parameters:

  • vk_name (String, Symbol)

    Virtual key name.

Returns:

  • (Fixnum, nil)

    Virtual key constant code if successful.

See Also:

Since:

  • 3.0.0


32
33
# File 'Documentation/ams/keyboard.rb', line 32

def get_key_code(vk_name)
end

.get_key_name(vk_code) ⇒ String?

Get virtual key name associated with the virtual key code.

Parameters:

  • vk_code (Fixnum)

    Virtual key code.

Returns:

  • (String, nil)

    Virtual key name or nil if vk_code is invalid.

See Also:

Since:

  • 3.5.0


41
42
# File 'Documentation/ams/keyboard.rb', line 41

def get_key_name(vk_code)
end

.get_key_state(vk) ⇒ Fixnum Also known as: key

Get virtual key state.

Parameters:

  • vk (String, Symbol, Fixnum)

    Virtual key name or key code.

Returns:

  • (Fixnum)

    1 if down or 0 if up.

See Also:

Since:

  • 2.0.0


13
14
# File 'Documentation/ams/keyboard.rb', line 13

def get_key_state(vk)
end

.get_keyboard_stateArray<Fixnum>

Note:

Windows only!

Get an array of all virtual key states.

Returns:

  • (Array<Fixnum>)

    An array of 256 values of 1 (down) or 0 (up).

See Also:

Since:

  • 2.0.0


23
24
# File 'Documentation/ams/keyboard.rb', line 23

def get_keyboard_state
end

.gey_virtual_key_codesHash<String, Fixnum>

Get general virtual key names and their associated key codes.

Returns:

  • (Hash<String, Fixnum>)

Since:

  • 3.0.0


47
48
# File 'Documentation/ams/keyboard.rb', line 47

def gey_virtual_key_codes
end

.gey_virtual_key_codes2Hash<String, Fixnum>

Get extended virtual key names and their associated key codes.

Returns:

  • (Hash<String, Fixnum>)

Since:

  • 3.0.0


53
54
# File 'Documentation/ams/keyboard.rb', line 53

def gey_virtual_key_codes2
end

.gey_virtual_key_namesHash<Fixnum, String>

Get virtual key codes and their associated key names.

Returns:

  • (Hash<Fixnum, String>)

Since:

  • 3.0.0


59
60
# File 'Documentation/ams/keyboard.rb', line 59

def gey_virtual_key_names
end

.key_down?(vk) ⇒ Boolean

Determine whether virtual key is down.

Parameters:

  • vk (String, Symbol, Fixnum)

    Virtual key name or key code.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0


76
77
# File 'Documentation/ams/keyboard.rb', line 76

def key_down?(vk)
end

.key_toggled?(vk) ⇒ Boolean

Note:

Windows only!

Determine whether virtual key is toggled.

Parameters:

  • vk (String, Symbol, Fixnum)

    Virtual key name or key code.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0


68
69
# File 'Documentation/ams/keyboard.rb', line 68

def key_toggled?(vk)
end

.key_up?(vk) ⇒ Boolean

Determine whether virtual key is up.

Parameters:

  • vk (String, Symbol, Fixnum)

    Virtual key name or key code.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0


92
93
# File 'Documentation/ams/keyboard.rb', line 92

def key_up?(vk)
end

.keys_down?(*vks) ⇒ Boolean

Determine whether an array of virtual keys are down.

Parameters:

  • vks (Array<String, Symbol, Fixnum>)

    Virtual key names or key codes.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0


84
85
# File 'Documentation/ams/keyboard.rb', line 84

def keys_down?(*vks)
end

.keys_up?(*vks) ⇒ Boolean

Determine whether an array of virtual keys are up.

Parameters:

  • vks (Array<String, Symbol, Fixnum>)

    Virtual key names or key codes.

Returns:

  • (Boolean)

See Also:

Since:

  • 2.0.0


100
101
# File 'Documentation/ams/keyboard.rb', line 100

def keys_up?(*vks)
end

.lbutton_down?Boolean

Note:

Windows only!

Determine whether left mouse button is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


144
145
# File 'Documentation/ams/keyboard.rb', line 144

def lbutton_down?
end

.lbutton_up?Boolean

Note:

Windows only!

Determine whether left mouse button is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


150
151
# File 'Documentation/ams/keyboard.rb', line 150

def lbutton_up?
end

.lcontrol_down?Boolean Also known as: lctrl_down?

Determine whether left CTRL key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


223
224
# File 'Documentation/ams/keyboard.rb', line 223

def lcontrol_down?
end

.lcontrol_up?Boolean Also known as: lctrl_up?

Determine whether left CTRL key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


230
231
# File 'Documentation/ams/keyboard.rb', line 230

def lcontrol_up?
end

Determine whether left ALT key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


251
252
# File 'Documentation/ams/keyboard.rb', line 251

def lmenu_down?
end

Determine whether left ALT key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


258
259
# File 'Documentation/ams/keyboard.rb', line 258

def lmenu_up?
end

.lshift_down?Boolean

Determine whether left SHIFT key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


203
204
# File 'Documentation/ams/keyboard.rb', line 203

def lshift_down?
end

.lshift_up?Boolean

Determine whether left SHIFT key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


208
209
# File 'Documentation/ams/keyboard.rb', line 208

def lshift_up?
end

.mbutton_down?Boolean

Note:

Windows only!

Determine whether middle mouse button is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


168
169
# File 'Documentation/ams/keyboard.rb', line 168

def mbutton_down?
end

.mbutton_up?Boolean

Note:

Windows only!

Determine whether middle mouse button is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


174
175
# File 'Documentation/ams/keyboard.rb', line 174

def mbutton_up?
end

Determine whether ALT key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


105
106
# File 'Documentation/ams/keyboard.rb', line 105

def menu_down?
end

Determine whether ALT key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


112
113
# File 'Documentation/ams/keyboard.rb', line 112

def menu_up?
end

.rbutton_down?Boolean

Note:

Windows only!

Determine whether right mouse button is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


156
157
# File 'Documentation/ams/keyboard.rb', line 156

def rbutton_down?
end

.rbutton_up?Boolean

Note:

Windows only!

Determine whether right mouse button is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


162
163
# File 'Documentation/ams/keyboard.rb', line 162

def rbutton_up?
end

.rcontrol_down?Boolean Also known as: rctrl_down?

Determine whether right CTRL key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


237
238
# File 'Documentation/ams/keyboard.rb', line 237

def rcontrol_down?
end

.rcontrol_up?Boolean Also known as: rctrl_up?

Determine whether right CTRL key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


244
245
# File 'Documentation/ams/keyboard.rb', line 244

def rcontrol_up?
end

.rmenu_down?Boolean Also known as: ralt_down?

Determine whether right ALT key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


265
266
# File 'Documentation/ams/keyboard.rb', line 265

def rmenu_down?
end

.rmenu_up?Boolean Also known as: ralt_up?

Determine whether right ALT key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


272
273
# File 'Documentation/ams/keyboard.rb', line 272

def rmenu_up?
end

.rshift_down?Boolean

Determine whether right SHIFT key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


213
214
# File 'Documentation/ams/keyboard.rb', line 213

def rshift_down?
end

.rshift_up?Boolean

Determine whether right SHIFT key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


218
219
# File 'Documentation/ams/keyboard.rb', line 218

def rshift_up?
end

.send_hardware_input(msg, wParamL, wParamH) ⇒ Fixnum

Note:

Windows only!

Note:

Be cautions when calling these from user input callbacks.

Send hardware input.

Parameters:

  • msg (Fixnum)
  • wParamL (Fixnum)
  • wParamH (Fixnum)

Returns:

  • (Fixnum)

See Also:

Since:

  • 3.6.0


325
326
# File 'Documentation/ams/keyboard.rb', line 325

def send_hardware_input(msg, wParamL, wParamH)
end

.send_keyboard_input(vk, scan, flags, time) ⇒ Fixnum

Note:

Windows only!

Note:

Be cautions when calling these from user input callbacks.

Send keyboard input.

Parameters:

  • vk (Fixnum)
  • scan (Fixnum)
  • flags (Fixnum)
  • time (Fixnum)

Returns:

  • (Fixnum)

See Also:

Since:

  • 3.6.0


312
313
# File 'Documentation/ams/keyboard.rb', line 312

def send_keyboard_input(vk, scan, flags, time)
end

.send_mouse_input(dx, dy, mouse_data, flags, time) ⇒ Fixnum

Note:

Windows only!

Note:

Be cautions when calling these from user input callbacks.

Send mouse input.

Examples:

Performing left-click

# Get cursor position in absolute coordinates
x,y = AMS::Cursor.get_pos(1)
# First, send left-mouse-button-down
AMS::Keyboard.send_mouse_input(x, y, 0, 0x0002, 0)
# Then, send left-mouse-button-up
AMS::Keyboard.send_mouse_input(x, y, 0, 0x0004, 0)
# OR Send both at once
AMS::Keyboard.send_mouse_input(x, y, 0, 0x0002 | 0x0004, 0)

Parameters:

  • dx (Fixnum)
  • dy (Fixnum)
  • mouse_data (Fixnum)
  • flags (Fixnum)
  • time (Fixnum)

Returns:

  • (Fixnum)

See Also:

Since:

  • 3.6.0


298
299
# File 'Documentation/ams/keyboard.rb', line 298

def send_mouse_input(dx, dy, mouse_data, flags, time)
end

.shift_down?Boolean

Determine whether SHIFT key is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


133
134
# File 'Documentation/ams/keyboard.rb', line 133

def shift_down?
end

.shift_up?Boolean

Determine whether SHIFT key is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


138
139
# File 'Documentation/ams/keyboard.rb', line 138

def shift_up?
end

.xbutton1_down?Boolean

Note:

Windows only!

Determine whether X1 mouse button is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


180
181
# File 'Documentation/ams/keyboard.rb', line 180

def xbutton1_down?
end

.xbutton1_up?Boolean

Note:

Windows only!

Determine whether X1 mouse button is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


186
187
# File 'Documentation/ams/keyboard.rb', line 186

def xbutton1_up?
end

.xbutton2_down?Boolean

Note:

Windows only!

Determine whether X2 mouse button is down.

Returns:

  • (Boolean)

Since:

  • 2.0.0


192
193
# File 'Documentation/ams/keyboard.rb', line 192

def xbutton2_down?
end

.xbutton2_up?Boolean

Note:

Windows only!

Determine whether X2 mouse button is up.

Returns:

  • (Boolean)

Since:

  • 2.0.0


198
199
# File 'Documentation/ams/keyboard.rb', line 198

def xbutton2_up?
end