Skip to content

Instantly share code, notes, and snippets.

@MangelMaxime
Last active September 7, 2016 19:35
Show Gist options
  • Save MangelMaxime/7450ad0bcf6809ac221783ac454bf240 to your computer and use it in GitHub Desktop.
Save MangelMaxime/7450ad0bcf6809ac221783ac454bf240 to your computer and use it in GitHub Desktop.
namespace Fable.Import.KeyboardJS
open System
open Fable.Core
open Fable.Import.JS
open Fable.Import.Browser
type [<AllowNullLiteral>] KeyEvent =
abstract preventRepeat: unit -> unit
and Callback =
[<Emit("$0($1...)")>] abstract Invoke: ?e: KeyEvent -> unit
type [<Global>] keyboardJS =
static member bind(keyCombo: U2<string, ResizeArray<string>>, pressed: (KeyEvent->unit), ?released: (KeyEvent->unit), ?preventRepeatByDefault: bool): unit = failwith "JS only"
static member unbind(keyCombo: U2<string, ResizeArray<string>>, ?pressed: (KeyEvent->unit), ?released: (KeyEvent->unit)): unit = failwith "JS only"
static member unbind(keyCombo: U2<string, ResizeArray<string>>, ?pressed: Callback, ?released: Callback): unit = failwith "JS only"
static member setContext(identifier: string): unit = failwith "JS only"
static member withContext(identifier: string, inContextCallBack: Func<unit>): unit = failwith "JS only"
static member getContext(): string = failwith "JS only"
static member pause(): unit = failwith "JS only"
static member resume(): unit = failwith "JS only"
static member reset(): unit = failwith "JS only"
static member pressKey(keyCombo: string): unit = failwith "JS only"
static member releaseKey(keyCombo: string): unit = failwith "JS only"
static member releaseAllKeys(): unit = failwith "JS only"
static member watch(myWin: Window, myDoc: U2<Document, HTMLElement>): unit = failwith "JS only"
static member watch(myDoc: U2<Document, HTMLElement>): unit = failwith "JS only"
static member watch(): unit = failwith "JS only"
static member stop(): unit = failwith "JS only"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment