{"id":6173,"date":"2020-11-16T21:56:22","date_gmt":"2020-11-16T19:56:22","guid":{"rendered":"http:\/\/www.kameli.net\/marq\/?p=6173"},"modified":"2020-11-16T21:56:22","modified_gmt":"2020-11-16T19:56:22","slug":"processing-3-and-right-left-shift","status":"publish","type":"post","link":"http:\/\/www.kameli.net\/marq\/?p=6173","title":{"rendered":"Processing 3 and right\/left shift"},"content":{"rendered":"\n<p>In Processing 2 it was relatively easy to tell the difference between the right and left shift by overriding <em>keyPressed(java.awt.event.KeyEvent ke)<\/em>, but in Processing 3 event handling has changed and the function doesn&#8217;t even get called any more. I really really wanted to use the two keys differently and came up with this\u00a0blurb for the <em>keyPressed() <\/em>handler:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if(keyCode==SHIFT)\n{\n  java.awt.event.KeyEvent ke;\n  ke=(java.awt.event.KeyEvent)keyEvent.getNative();\n\n  if(ke.getKeyLocation()==KeyEvent.KEY_LOCATION_LEFT)\n  {\n    \/\/ It's the left shift\n  }\n}<\/code><\/pre>\n\n\n\n<p>Note that this will only work with the default renderer, as the others don&#8217;t use AWT. The &#8220;solution&#8221; is also deprecated, so it might stop working any time and then we need another hack to work around the issue. Things would be so much easier if Processing simply provided a different <em>keyCode<\/em> for the two keys, but I wouldn&#8217;t hold my breath waiting for that.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Processing 2 it was relatively easy to tell the difference between the right and left shift by overriding keyPressed(java.awt.event.KeyEvent ke), but in Processing 3 event handling has changed and the function doesn&#8217;t even get called any more. I really really wanted to use the two keys differently and came up with this\u00a0blurb for the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25,24],"tags":[],"class_list":["post-6173","post","type-post","status-publish","format-standard","hentry","category-koodi","category-softat"],"_links":{"self":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/posts\/6173","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6173"}],"version-history":[{"count":1,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/posts\/6173\/revisions"}],"predecessor-version":[{"id":6174,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=\/wp\/v2\/posts\/6173\/revisions\/6174"}],"wp:attachment":[{"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6173"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6173"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.kameli.net\/marq\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6173"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}