You are here

protected function KeyboardTrait::normalizeCharForKeyEvent in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/jcalderonzumba/mink-phantomjs-driver/src/KeyboardTrait.php \Zumba\Mink\Driver\KeyboardTrait::normalizeCharForKeyEvent()

Does some normalization for the char we want to do keyboard events with.

Parameters

$char:

Return value

string

Throws

DriverException

3 calls to KeyboardTrait::normalizeCharForKeyEvent()
KeyboardTrait::keyDown in vendor/jcalderonzumba/mink-phantomjs-driver/src/KeyboardTrait.php
Send a key-down event to the browser element
KeyboardTrait::keyPress in vendor/jcalderonzumba/mink-phantomjs-driver/src/KeyboardTrait.php
KeyboardTrait::keyUp in vendor/jcalderonzumba/mink-phantomjs-driver/src/KeyboardTrait.php
Pressed up specific keyboard key.

File

vendor/jcalderonzumba/mink-phantomjs-driver/src/KeyboardTrait.php, line 19

Class

KeyboardTrait
Class KeyboardTrait @package Zumba\Mink\Driver

Namespace

Zumba\Mink\Driver

Code

protected function normalizeCharForKeyEvent($char) {
  if (!is_int($char) && !is_string($char)) {
    throw new DriverException("Unsupported key type, can only be integer or string");
  }
  if (is_string($char) && strlen($char) !== 1) {
    throw new DriverException("Key can only have ONE character");
  }
  $key = $char;
  if (is_int($char)) {
    $key = chr($char);
  }
  return $key;
}