KeyboardEvent
Represents the event arguments for a keyboard event.
using AngleSharp.Attributes;
namespace AngleSharp.Dom.Events
{
[DomName("KeyboardEvent")]
public class KeyboardEvent : UiEvent
{
private string _modifiers;
[DomName("key")]
public string Key { get; set; }
[DomName("location")]
public KeyboardLocation Location { get; set; }
[DomName("ctrlKey")]
public bool IsCtrlPressed {
get {
return _modifiers.IsCtrlPressed();
}
}
[DomName("shiftKey")]
public bool IsShiftPressed {
get {
return _modifiers.IsShiftPressed();
}
}
[DomName("altKey")]
public bool IsAltPressed {
get {
return _modifiers.IsAltPressed();
}
}
[DomName("metaKey")]
public bool IsMetaPressed {
get {
return _modifiers.IsMetaPressed();
}
}
[DomName("repeat")]
public bool IsRepeated { get; set; }
[DomName("locale")]
public string Locale {
get {
if (!base.IsTrusted)
return null;
return string.Empty;
}
}
public KeyboardEvent()
{
}
[DomConstructor]
[DomInitDict(1, true)]
public KeyboardEvent(string type, bool bubbles = false, bool cancelable = false, IWindow view = null, int detail = 0, string key = null, KeyboardLocation location = KeyboardLocation.Standard, string modifiersList = null, bool repeat = false)
{
Init(type, bubbles, cancelable, view, detail, key ?? string.Empty, location, modifiersList ?? string.Empty, repeat);
}
[DomName("getModifierState")]
public bool GetModifierState(string key)
{
return _modifiers.ContainsKey(key);
}
[DomName("initKeyboardEvent")]
public void Init(string type, bool bubbles, bool cancelable, IWindow view, int detail, string key, KeyboardLocation location, string modifiersList, bool repeat)
{
Init(type, bubbles, cancelable, view, detail);
Key = key;
Location = location;
IsRepeated = repeat;
_modifiers = modifiersList;
}
}
}