{"id":1110,"date":"2018-10-24T20:53:01","date_gmt":"2018-10-24T20:53:01","guid":{"rendered":"https:\/\/lab.florianschwarz.net\/PennController\/?post_type=yada_wiki&#038;p=1110"},"modified":"2018-11-01T17:01:08","modified_gmt":"2018-11-01T17:01:08","slug":"key-test-pressed","status":"publish","type":"yada_wiki","link":"https:\/\/lab.florianschwarz.net\/PennController\/wiki\/key-test-pressed\/","title":{"rendered":"key.test.pressed"},"content":{"rendered":"<p class='command-format'><code>getKey(id).test.pressed()<\/code><\/p>\n<p class='command-format'>or <code>getKey(id).test.pressed( string )<\/code><\/p>\n<p class='command-format'>or <code>getKey(id).test.pressed( string , \"first\" )<\/code> <em>(since beta 0.3)<\/em><\/p>\n<p class='command-format'>or <code>getKey(id).test.pressed( number )<\/code><\/p>\n<p class='command-format'>or <code>getKey(id).test.pressed( number , \"first\" )<\/code> <em>(since beta 0.3)<\/em><\/p>\n<p>Tests whether a key was pressed.<\/p>\n<p>If you pass no argument, it will yield success if any (valid) key has been pressed since the creation of the Key element. If you pass a string, it will test that the pressed key(s) is\/are contained in the string. Alternatively you can pass a number representing a charCode. Since beta 0.3, if you pass a string as a second parameter (e.g. <em>&#8220;first&#8221;<\/em>) then only the first valid key that was pressed since the creation of the Key element will be tested.<\/p>\n<p><strong>Example:<\/strong><\/p>\n<p>[js highlight=&#8221;8&#8243; try=&#8221;true&#8221;]newText(&#8220;instructions&#8221;, &#8220;Press F if you think 0.999&#8230; = 1, press J otherwise.&#8221;)<br \/>\n    .print()<br \/>\n,<br \/>\nnewKey(&#8220;forj&#8221;, &#8220;FJ&#8221;)<br \/>\n    .wait()<br \/>\n,<br \/>\ngetKey(&#8220;forj&#8221;)<br \/>\n    .test.pressed(&#8220;F&#8221;)<br \/>\n    .success( newText(&#8220;success&#8221;, &#8220;You&#8217;re right!&#8221;).print() )<br \/>\n    .failure( newText(&#8220;failure&#8221;, &#8220;You&#8217;re wrong, 0.999&#8230; and 1 do refer to the same number&#8221;).print() )<br \/>\n[\/js]<\/p>\n<p>Will print the success message if the key that was pressed was F. Will print the failure message otherwise (i.e., if it was J).<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"inline_featured_image":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"wiki_cats":[13,5,4,22,15],"wiki_tags":[],"class_list":["post-1110","yada_wiki","type-yada_wiki","status-publish","hentry","wiki_cats-command","wiki_cats-documentation","wiki_cats-element","wiki_cats-key-element","wiki_cats-test-command"],"_links":{"self":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki"}],"about":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/types\/yada_wiki"}],"author":[{"embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/comments?post=1110"}],"version-history":[{"count":3,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1110\/revisions"}],"predecessor-version":[{"id":1613,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/yada_wiki\/1110\/revisions\/1613"}],"wp:attachment":[{"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/media?parent=1110"}],"wp:term":[{"taxonomy":"wiki_cats","embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/wiki_cats?post=1110"},{"taxonomy":"wiki_tags","embeddable":true,"href":"https:\/\/lab.florianschwarz.net\/PennController\/wp-json\/wp\/v2\/wiki_tags?post=1110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}