Skip to content

KeyboardEvent.key support for control and special characters #722

@blasss

Description

@blasss

We are happily using HtmlUnit 3.4 with Selenium and wanted to get rid of some legacy usage of the deprecated KeyboardEvent.keyCode in our web application.
The most portable replacement would be KeyboardEvent.key, but this is currently not working for arrow keys. For example sendKeys(Keys.UP) on a element yields & in JavaScript for KeyboardEvent.key as opposed to the expected "ArrowUp". & in ASCII is 0x26 which is the corresponding KeyboardEvent.keyCode.

Stating from the implementation the current support for KeyboardEvent.key seems to be limited to printable characters, "Shift", "Enter" and Period (KeyboardEvent.determineKey()).

As KeyboardEvent.key is part of the W3C UI Events standard and is broadly supported by current browsers (caniuse) it would be really nice to have this as well in HtmlUnit.
Mozilla provides a extensive table of common control and special characters in the mdn

Thanks for the continuous support and effort you put into HtmlUnit.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions