Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: added missing input transformations #2186

Merged
merged 2 commits into from
May 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/bidiMapper/modules/input/keyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
* limitations under the License.
*/

/**
* Returns the normalized key value for a given key according to the table:
* https://w3c.github.io/webdriver/#dfn-normalized-key-value
*/
export function getNormalizedKey(value: string): string {
switch (value) {
case '\uE000':
Expand Down Expand Up @@ -162,6 +166,10 @@ export function getNormalizedKey(value: string): string {
}
}

/**
* Returns the key code for a given key according to the table:
* https://w3c.github.io/webdriver/#dfn-shifted-character
*/
export function getKeyCode(key: string): string | undefined {
switch (key) {
case '`':
Expand Down Expand Up @@ -214,6 +222,10 @@ export function getKeyCode(key: string): string | undefined {
case '=':
case '+':
return 'Equal';
// The spec declares the '<' to be `IntlBackslash` as well, but it is already covered
// in the `Comma` above.
case '>':
return 'IntlBackslash';
case 'a':
case 'A':
return 'KeyA';
Expand Down Expand Up @@ -316,6 +328,8 @@ export function getKeyCode(key: string): string | undefined {
return 'ControlRight';
case '\uE006':
return 'Enter';
case '\uE00B':
return 'Pause';
case '\uE03D':
return 'MetaLeft';
case '\uE053':
Expand Down Expand Up @@ -377,6 +391,8 @@ export function getKeyCode(key: string): string | undefined {
return 'F11';
case '\uE03C':
return 'F12';
case '\uE019':
return 'NumpadEqual';
case '\uE01A':
case '\uE05C':
return 'Numpad0';
Expand Down Expand Up @@ -426,6 +442,10 @@ export function getKeyCode(key: string): string | undefined {
}
}

/**
* Returns the location of the key according to the table:
* https://w3c.github.io/webdriver/#dfn-key-location
*/
export function getKeyLocation(key: string): 0 | 1 | 2 | 3 {
switch (key) {
case '\uE007':
Expand All @@ -434,6 +454,7 @@ export function getKeyLocation(key: string): 0 | 1 | 2 | 3 {
case '\uE00A':
case '\uE03D':
return 1;
case '\uE019':
case '\uE01A':
case '\uE01B':
case '\uE01C':
Expand Down
Loading