Module: SendKeys
- Defined in:
- lib/monkey-patches/send-keys.rb
Instance Method Summary collapse
Instance Method Details
#allowed_keys ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/monkey-patches/send-keys.rb', line 2 def allowed_keys @allowed_keys ||= %w( option null cancel help backspace tab clear return enter shift left_shift control left_control alt left_alt pause escape space page_up page_down end home left arrow_left arrow_up right arrow_rightdown arrow_down insert delete semicolon equals numpad0 numpad1 numpad2 numpad3 numpad4 numpad5 numpad6 numpad7 numpad8 numpad9 multiplyadd separator subtract decimal divide f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11 f12 ) end |
#send_string_of_keys(key) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/monkey-patches/send-keys.rb', line 46 def send_string_of_keys(key) send_key = [] if matches = key.match(%r{^\[(.*)\]$}) key = matches[1].split(',').map(&:strip) else key = [key] end key.each do |k| if matches = k.match(%r{^['"](.*)['"]$}) send_key << matches[1] elsif allowed_keys.include?(k) send_key << k.to_sym else send_key << k.to_s end end native.send_keys(send_key) end |