Skip to content

Commit

Permalink
core: add key codes module
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed May 12, 2024
1 parent a1621cf commit c4a4296
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 5 deletions.
36 changes: 35 additions & 1 deletion marionette-doc/scribblings/marionette.scrbl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
scribble/example
(for-label json
marionette
marionette/key
net/url
racket/base
racket/contract/base
Expand Down Expand Up @@ -409,7 +410,9 @@ you got it from, it becomes invalid.

@defproc[(element-type! [e element?]
[text string?]) void]{
Types @racket[text] into @racket[e].
Types @racket[text] into @racket[e]. To type special characters,
such as the ``return'' key, splice the bindings provided by the
@racketmod[marionette/key] module into @racket[text].
}

@deftogether[
Expand Down Expand Up @@ -504,3 +507,34 @@ you got it from, it becomes invalid.
@deftech{Timeouts} let you control how long the browser will wait
for various operations to finish before raising an exception.
}


@subsection[#:tag "reference/keys"]{Keys}
@defmodule[marionette/key]

This module provides bindings for special control characters that can
be typed into an @tech{element} or alert. Some examples:

@deftogether[(
@defthing[key:backspace char?]
@defthing[key:command char?]
@defthing[key:control char?]
@defthing[key:enter char?]
@defthing[key:escape char?]
@defthing[key:meta char?]
@defthing[key:shift char?]
@defthing[key:tab char?]
)]{

Some of the bindings provided by this module. To see all of them,
run the following code at a REPL:

@racketblock[
(require marionette/key)
(map car (call-with-values
(lambda () (module->exports 'marionette/key))
(compose1 cdaar list)))
]

@history[#:added "1.3"]
}
2 changes: 1 addition & 1 deletion marionette-lib/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2019 Bogdan Popa <[email protected]>
Copyright 2019-2024 Bogdan Popa <[email protected]>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
Expand Down
69 changes: 69 additions & 0 deletions marionette-lib/key.rkt
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#lang racket/base

#|review: ignore|#

(provide (prefix-out key: (all-defined-out)))

(define null #\uE000)
(define cancel #\uE001)
(define help #\uE002)
(define backspace #\uE003)
(define tab #\uE004)
(define clear #\uE005)
(define return #\uE006)
(define enter #\uE007)
(define shift #\uE008)
(define left-shift #\uE008)
(define control #\uE009)
(define left-control #\uE009)
(define alt #\uE00a)
(define left-alt #\uE00a)
(define pause #\uE00b)
(define escape #\uE00c)
(define space #\uE00d)
(define page-up #\uE00e)
(define page-down #\uE00f)
(define end #\uE010)
(define home #\uE011)
(define left #\uE012)
(define arrow-left #\uE012)
(define up #\uE013)
(define arrow-up #\uE013)
(define right #\uE014)
(define arrow-right #\uE014)
(define down #\uE015)
(define arrow-down #\uE015)
(define insert #\uE016)
(define delete #\uE017)
(define semicolon #\uE018)
(define equals #\uE019)
(define numpad-0 #\uE01a)
(define numpad-1 #\uE01b)
(define numpad-2 #\uE01c)
(define numpad-3 #\uE01d)
(define numpad-4 #\uE01e)
(define numpad-5 #\uE01f)
(define numpad-6 #\uE020)
(define numpad-7 #\uE021)
(define numpad-8 #\uE022)
(define numpad-9 #\uE023)
(define multiply #\uE024)
(define add #\uE025)
(define separator #\uE026)
(define subtract #\uE027)
(define decimal #\uE028)
(define divide #\uE029)
(define f1 #\uE031)
(define f2 #\uE032)
(define f3 #\uE033)
(define f4 #\uE034)
(define f5 #\uE035)
(define f6 #\uE036)
(define f7 #\uE037)
(define f8 #\uE038)
(define f9 #\uE039)
(define f10 #\uE03a)
(define f11 #\uE03b)
(define f12 #\uE03c)
(define meta #\uE03d)
(define command #\uE03d)
2 changes: 1 addition & 1 deletion marionette-lib/page.rkt
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
(marionette-execute-script! (page-marionette p) s args)
res-value))))

(define (wrap-async-script body)
(define (wrap-async-script body) ;; noqa
(template "support/wrap-async-script.js"))

(define (page-execute-async! p s . args)
Expand Down
2 changes: 1 addition & 1 deletion marionette-test/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2019 Bogdan Popa <[email protected]>
Copyright 2019-2024 Bogdan Popa <[email protected]>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
Expand Down
2 changes: 1 addition & 1 deletion marionette/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright 2019 Bogdan Popa <[email protected]>
Copyright 2019-2024 Bogdan Popa <[email protected]>

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
Expand Down

0 comments on commit c4a4296

Please sign in to comment.