View Source Playwright.Page.Keyboard (playwright v1.44.0-alpha.4)

Keyboard provides an API for managing a virtual keyboard. The high level API is keyboard.type(), which takes raw characters and generates proper keydown, keypress/input, and keyup events on your page.

For finer control, you can use keyboard.down(), keyboard.up(), and keyboard.insertText() to manually fire events as if they were generated from a real keyboard.

Examples

###

Summary

Types

t()

%Playwright.Page.Keyboard{}

Functions

Optional callback implementation for Playwright.SDK.ChannelOwner.init/2.

Types

@type t() :: %Playwright.Page.Keyboard{
  guid: term(),
  initializer: term(),
  listeners: term(),
  parent: term(),
  session: term(),
  type: term()
}

%Playwright.Page.Keyboard{}

Functions

Link to this function

init(owner, initializer)

View Source
@spec init(
  struct(),
  map()
) :: {atom(), struct()}

Optional callback implementation for Playwright.SDK.ChannelOwner.init/2.

If implemented, the callback will receive:

  1. The newly created "channel owner" struct.
  2. The :initializer received from the Playwright browser server.

The implementation has the option of "patching" the struct as stored in the catalog, and/or binding event handlers.

Example

def init(%{session: session} = owner, _initializer) do
  Channel.bind(session, {:guid, owner.guid}, :close, fn event ->
    Logger.warning("Closing #{inspect(event.target)}")
  end)

  {:ok, %{owner | version: "1.2.3"}}
end

Returns

  • {:ok, struct()}

Arguments

key/nametypedescription
ownerparamstruct()The newly created channel owner (resource).
initializerparamstruct()The initializer received from with the channel owner instance was derived.
@spec insert_text(Playwright.Page.t(), binary()) :: Playwright.Page.t()
@spec press(Playwright.Page.t(), binary()) :: Playwright.Page.t()