Skip to content

Commit

Permalink
add various key-related fields to KeyboardEvent
Browse files Browse the repository at this point in the history
Add KeyIdentifier, KeyCode and KeyLocation fields to KeyboardEvent.
Apparently, the whole "keyboard input" situation in JavaScript is a
mess, with different browsers implementing different (non-standard)
behaviours, some browsers supporting newer standards and some browsers
not supporting them or only supporting deprecated versions of them.
Behaviour might even differ between the different input
events (keypress, keydown and so on.)

We'll simply add all the attributes there could possibly be. Writing a
cross-browser abstraction that hides these details is out of scope and
left to a third party.
  • Loading branch information
dominikh committed Sep 9, 2014
1 parent 928aad6 commit 73b8f9a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,18 @@ const (

type KeyboardEvent struct {
*BasicEvent
AltKey bool `js:"altKey"`
CharCode int `js:"charCode"`
CtrlKey bool `js:"ctrlKey"`
Key string `js:"key"`
Locale string `js:"locale"`
Location int `js:"location"`
MetaKey bool `js:"metaKey"`
Repeat bool `js:"repeat"`
ShiftKey bool `js:"shiftKey"`
AltKey bool `js:"altKey"`
CharCode int `js:"charCode"`
CtrlKey bool `js:"ctrlKey"`
Key string `js:"key"`
KeyIdentifier string `js:"keyIdentifier"`
KeyCode int `js:"keyCode"`
Locale string `js:"locale"`
Location int `js:"location"`
KeyLocation int `js:"keyLocation"`
MetaKey bool `js:"metaKey"`
Repeat bool `js:"repeat"`
ShiftKey bool `js:"shiftKey"`
}

func (ev *KeyboardEvent) ModifierState(mod string) bool {
Expand Down

0 comments on commit 73b8f9a

Please sign in to comment.