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

Commit

Permalink
Merge pull request #102 from grumpi/KeyboardEvent-documentation-impro…
Browse files Browse the repository at this point in the history
…vement

A tiny bit of documentation for KeyboardEvent
  • Loading branch information
garyb authored Jun 4, 2017
2 parents 4cfb68d + ffca4a8 commit fd260ed
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/DOM/Event/KeyboardEvent.purs
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
-- | Functions that expose the KeyboardEvent API.
-- |
-- | https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent
-- |
-- | Note: The deprecated attributes `.keyCode`, `.charCode`, and
-- | `.which` are deliberately omitted. It is currently recommended to use
-- | `KeyboardEvent.key` instead.
-- |
-- | If browser support for `KeyboardEvent.key` is not yet widespread
-- | enough for your use case, consider using a polyfill
-- | (e.g. https://github.com/inexorabletash/polyfill#keyboard-events)
-- | or use the purescript FFI to access the deprecated attributes you
-- | want to work with.
-- |
module DOM.Event.KeyboardEvent
( module T
, eventToKeyboardEvent
Expand Down Expand Up @@ -29,8 +43,12 @@ import DOM.Event.Types (KeyboardEvent, keyboardEventToEvent, readKeyboardEvent)
eventToKeyboardEvent :: Event -> F KeyboardEvent
eventToKeyboardEvent = readKeyboardEvent <<< toForeign

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

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

foreign import locationIndex :: KeyboardEvent -> Int
Expand Down

0 comments on commit fd260ed

Please sign in to comment.