Method: AX::Application#hold_modifier

Defined in:
lib/ax/application.rb

#hold_modifier(key) ⇒ Number?

Press the given modifier key and hold it down while yielding to the given block. As with #type, the key events apply to the control element which is currently focused.

Examples:


hold_modifier "\\CONTROL" do
  drag_mouse_to point
end

Parameters:

  • key (String)

Returns:

  • (Number, nil)


326
327
328
329
330
331
332
333
334
# File 'lib/ax/application.rb', line 326

def hold_modifier key
  code = EventGenerator::CUSTOM[key]
  raise ArgumentError, "Invalid modifier `#{key}' given" unless code
  KeyCoder.post_event([code, true])
  yield
ensure
  KeyCoder.post_event([code, false]) if code
  code
end