From 00a9f398a0a202afbd4cdaf2a0f00c0be6b560ce Mon Sep 17 00:00:00 2001 From: oakes Date: Sat, 10 May 2014 00:41:57 -0400 Subject: [PATCH] Improve descriptino of key-code --- TUTORIAL.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/TUTORIAL.md b/TUTORIAL.md index 5c1b5d3..cca9658 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -83,7 +83,9 @@ Let's add a new function at the end of `defscreen` called `:on-key-down`, which ) ``` -If takes the same form as the other functions, expecting a new entities vector to be returned at the end. The first argument, `screen`, which we haven't talked about yet, is a Clojure map containing various important values. In the `:on-key-down` function, it will contain a `:keycode` which indicates what key was pressed. See the [documentation](http://oakes.github.io/play-clj/core.key-code.html) to for all the possible keys. +If takes the same form as the other functions, expecting a new entities vector to be returned at the end. The first argument, `screen`, which we haven't talked about yet, is a Clojure map containing various important values. In the `:on-key-down` function, it will contain a `:keycode` which indicates what key was pressed. + +To figure out what key it refers to, you'll need to compare it to a known key code, which you can get with `key-code`. See [the documentation](http://oakes.github.io/play-clj/core.key-code.html) or the example below to learn how to use it. Let's write a conditional statement that prints out which arrow key you pressed. Note that if a `defscreen` function returns `nil`, it leaves the entities vector unchanged, so the code below won't wipe out the entities vector.