Skip to content
This repository was archived by the owner on Aug 23, 2018. It is now read-only.
This repository was archived by the owner on Aug 23, 2018. It is now read-only.

Keyboard.presses always returns code 0 #10

Open
@christianp

Description

@christianp

I've just been playing in Firefox 58, and Keyboard.presses always produces the KeyCode 0, no matter what key is pressed.
Keyboard.ups produces the right codes.

Here's a small example (on Ellie):

import Html exposing (..)
import Keyboard exposing (KeyCode, presses)


main =
  Html.program
    { init = init
    , view = view
    , update = update
    , subscriptions = subscriptions
    }


-- MODEL


type alias Model = Maybe KeyCode

init : ( Model, Cmd Msg )
init =
  ( Nothing, Cmd.none )



-- UPDATE


type Msg
    = SetCode KeyCode


update : Msg -> Model -> ( Model, Cmd Msg )
update (SetCode code) model = (Just code, Cmd.none)


-- SUBSCRIPTIONS


subscriptions : Model -> Sub Msg
subscriptions model = presses SetCode


-- VIEW


view model = div [] [text <| toString model]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions