class Capybara::Selenium::MarionetteNode

def _send_keys(keys, actions = browser_action, down_keys = ModifierKeysStack.new)

def _send_keys(keys, actions = browser_action, down_keys = ModifierKeysStack.new)
  case keys
  when :control, :left_control, :right_control,
       :alt, :left_alt, :right_alt,
       :shift, :left_shift, :right_shift,
       :meta, :left_meta, :right_meta,
       :command
    down_keys.press(keys)
    actions.key_down(keys)
  when String
    # https://bugzilla.mozilla.org/show_bug.cgi?id=1405370
    keys = keys.upcase if (browser_version < 64.0) && down_keys&.include?(:shift)
    actions.send_keys(keys)
  when Symbol
    actions.send_keys(keys)
  when Array
    down_keys.push
    keys.each { |sub_keys| _send_keys(sub_keys, actions, down_keys) }
    down_keys.pop.reverse_each { |key| actions.key_up(key) }
  else
    raise ArgumentError, 'Unknown keys type'
  end
  actions
end