Skip to content

[dotnet] Add representations for right modifier keys in Keys class #15960

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

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Open
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
36 changes: 36 additions & 0 deletions dotnet/src/webdriver/Keys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,36 @@ public static class Keys
/// </summary>
public static readonly string ZenkakuHankaku = Convert.ToString(Convert.ToChar(0xE040, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);

/// <summary>
/// Represents the right Shift key.
/// </summary>
public static readonly string RightShift = Convert.ToString(Convert.ToChar(0xE050, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);

/// <summary>
/// Represents the right Control key.
/// </summary>
public static readonly string RightControl = Convert.ToString(Convert.ToChar(0xE051, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);

/// <summary>
/// Represents the right Alt key.
/// </summary>
public static readonly string RightAlt = Convert.ToString(Convert.ToChar(0xE052, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);

/// <summary>
/// Represents the right Command key (macOS).
/// </summary>
public static readonly string RightCommand = Convert.ToString(Convert.ToChar(0xE053, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);

/// <summary>
/// Represents the macOS Options key (same Unicode value as RightShift).
/// </summary>
public static readonly string Options = Convert.ToString(Convert.ToChar(0xE050, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On macs, Option is equivalent to Alt (left and right)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That means Java key codes should be updated as well, along with the other implementations in this feature request. OPTION here is also equal to SHIFT

RIGHT_SHIFT('\uE050'), // aligns with ChromeDriver usage
RIGHT_CONTROL('\uE051'),
RIGHT_ALT('\uE052'),
RIGHT_COMMAND('\uE053'),
// Symbolic macOS keys not yet standardized
OPTION('\uE050'), // TODO: verify Unicode value with WebDriver spec


/// <summary>
/// Represents the macOS Function key (same Unicode value as RightControl).
/// </summary>
public static readonly string Function = Convert.ToString(Convert.ToChar(0xE051, CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);

private static Dictionary<string, string>? descriptions;

/// <summary>
Expand Down Expand Up @@ -422,6 +452,12 @@ internal static object GetDescription(string value)
descriptions.Add(Meta, "Meta");
descriptions.Add(Command, "Command");
descriptions.Add(ZenkakuHankaku, "Zenkaku Hankaku");
descriptions.Add(RightShift, "Right Shift");
descriptions.Add(RightControl, "Right Control");
descriptions.Add(RightAlt, "Right Alt");
descriptions.Add(RightCommand, "Right Command");
descriptions.Add(Options, "Options");
descriptions.Add(Function, "Function");
}

if (descriptions.TryGetValue(value, out string? description))
Expand Down