Skip to content
This repository was archived by the owner on Oct 4, 2020. It is now read-only.

Commit fd260ed

Browse files
authored
Merge pull request #102 from grumpi/KeyboardEvent-documentation-improvement
A tiny bit of documentation for KeyboardEvent
2 parents 4cfb68d + ffca4a8 commit fd260ed

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/DOM/Event/KeyboardEvent.purs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
-- | Functions that expose the KeyboardEvent API.
2+
-- |
3+
-- | https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
4+
-- |
5+
-- | Note: The deprecated attributes `.keyCode`, `.charCode`, and
6+
-- | `.which` are deliberately omitted. It is currently recommended to use
7+
-- | `KeyboardEvent.key` instead.
8+
-- |
9+
-- | If browser support for `KeyboardEvent.key` is not yet widespread
10+
-- | enough for your use case, consider using a polyfill
11+
-- | (e.g. https://github.com/inexorabletash/polyfill#keyboard-events)
12+
-- | or use the purescript FFI to access the deprecated attributes you
13+
-- | want to work with.
14+
-- |
115
module DOM.Event.KeyboardEvent
216
( module T
317
, eventToKeyboardEvent
@@ -29,8 +43,12 @@ import DOM.Event.Types (KeyboardEvent, keyboardEventToEvent, readKeyboardEvent)
2943
eventToKeyboardEvent :: Event -> F KeyboardEvent
3044
eventToKeyboardEvent = readKeyboardEvent <<< toForeign
3145

46+
-- | A non-empty Unicode character string containing the printable representation
47+
-- | of the key, if available.
3248
foreign import key :: KeyboardEvent -> String
3349

50+
-- | Returns a string representing a physical key on the keyboard. Not
51+
-- | affected by keyboard layout or state of the modifier keys.
3452
foreign import code :: KeyboardEvent -> String
3553

3654
foreign import locationIndex :: KeyboardEvent -> Int

0 commit comments

Comments
 (0)