Browser events
Browser events
(any-pressed?)
Is any key on the keyboard pressed?
Is any key on the keyboard pressed?
(ascii c)
A clojurescript version of ascii value of. javascript doesn't have a char type, but uses a string of length 1 to represent
A clojurescript version of ascii value of. javascript doesn't have a char type, but uses a string of length 1 to represent
(handle-keydown-event ev)
the base event handler for key down events. Takes the keycode and sets that key in the key-state dictionary to true
the base event handler for key down events. Takes the keycode and sets that key in the key-state dictionary to true
(handle-keyup-event ev)
the basic event handler for key up events. Takes the keycode and removes it as a key from the key-state dictionary
the basic event handler for key up events. Takes the keycode and removes it as a key from the key-state dictionary
(install-frame-handler!)
install the frame callback to send frame chan messages
install the frame callback to send frame chan messages
(install-key-handler!)
install the keyup and keydown event handlers
install the keyup and keydown event handlers
(install-resize-handler!)
install the resize callback to resize the main canvas renderer
install the resize callback to resize the main canvas renderer
(is-pressed? code)
returns true if the key is pressently down. code is a keyword, or a string of length 1. Examples:
;; test if keys are down by keyword
(is-pressed? :backspace)
(is-pressed? :f10)
(is-pressed? :left)
(is-pressed? :space)
(is-pressed? :w)
(is-pressed? :a)
;; test if keys are down by string
(is-pressed? " ")
(is-pressed? "w")
(is-pressed? "a")
(is-pressed? "d")
(is-pressed? "s")
See key-codes for a list of keyword keys.
returns true if the key is pressently down. code is a keyword, or a string of length 1. Examples: ``` ;; test if keys are down by keyword (is-pressed? :backspace) (is-pressed? :f10) (is-pressed? :left) (is-pressed? :space) (is-pressed? :w) (is-pressed? :a) ;; test if keys are down by string (is-pressed? " ") (is-pressed? "w") (is-pressed? "a") (is-pressed? "d") (is-pressed? "s") ``` See key-codes for a list of keyword keys.
A hashmap with a variety of keys (strings, keywords). mapping to browser key codes. Use the is-pressed? function to test keys directly.
Keycodes can be any string of length 1 representing a key (lowercase). Keycodes can also be any of the following keywords
:backspace :tab :enter :shift :control :alt :pause :capslock :esc :space :pageup :pagedown :end :home :left :up :right :down :insert :delete :f1 :f2 :f3 :f4 :f5 :f6 :f7 :f8 :f9 :f10 :f11 :f12 :numlock :scrolllock :comma :. :/ :backtick :squareleft :backslash :squareright :quote
or any of the single alphanumeric lowercase characters as keywords
eg. :w :a :s :d :1 :5 etc.
A hashmap with a variety of keys (strings, keywords). mapping to browser key codes. Use the is-pressed? function to test keys directly. Keycodes can be any string of length 1 representing a key (lowercase). Keycodes can also be any of the following keywords :backspace :tab :enter :shift :control :alt :pause :capslock :esc :space :pageup :pagedown :end :home :left :up :right :down :insert :delete :f1 :f2 :f3 :f4 :f5 :f6 :f7 :f8 :f9 :f10 :f11 :f12 :numlock :scrolllock :comma :. :/ :backtick :squareleft :backslash :squareright :quote or any of the single alphanumeric lowercase characters as keywords eg. :w :a :s :d :1 :5 etc.
(make-request-animation-frame)
compose a function that is the r-a-f func. returns a function. This returned function takes a callback and ensures its called next frame
compose a function that is the r-a-f func. returns a function. This returned function takes a callback and ensures its called next frame
(next-frame)
returns a single use channel which closes on next frame callback. pulling from it waits exactly one frame. eg
;; wait one frame
(<! (next-frame))
returns a single use channel which closes on next frame callback. pulling from it waits exactly one frame. eg ``` ;; wait one frame (<! (next-frame)) ```
schedules the passed in callback to be fired once, next animation frame.
schedules the passed in callback to be fired once, next animation frame.
(wait-frames frames)
returns a channel which closes when a certain number of frames have passed. eg
;; wait 10 frames
(<! (wait-frames 10))
returns a channel which closes when a certain number of frames have passed. eg ``` ;; wait 10 frames (<! (wait-frames 10)) ```
(wait-time delay)
returns a channel which closes when a certain amount of time in milliseconds has passed, but determines that time by counting the requestAnimationFrame callbacks, so that when tab focus is lost, the callback, and thus this wait is suspended.
;; wait one seconds worth of frames
(<! (wait-time 1000))
returns a channel which closes when a certain amount of time in milliseconds has passed, but determines that time by counting the requestAnimationFrame callbacks, so that when tab focus is lost, the callback, and thus this wait is suspended. ``` ;; wait one seconds worth of frames (<! (wait-time 1000)) ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close