input_Key.js.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>JSDoc: Source: input/Key.js</title>
  6. <script src="scripts/prettify/prettify.js"> </script>
  7. <script src="scripts/prettify/lang-css.js"> </script>
  8. <!--[if lt IE 9]>
  9. <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
  10. <![endif]-->
  11. <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
  12. <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
  13. </head>
  14. <body>
  15. <div id="main">
  16. <h1 class="page-title">Source: input/Key.js</h1>
  17. <section>
  18. <article>
  19. <pre class="prettyprint source linenums"><code>"use strict";
  20. /**
  21. * Key is used by Keyboard, Pointer, etc, to represent a key state.
  22. *
  23. * @class
  24. */
  25. function Key()
  26. {
  27. /**
  28. * Indicates if this key is currently pressed.
  29. */
  30. this.pressed = false;
  31. /**
  32. * Indicates if this key was just pressed.
  33. */
  34. this.justPressed = false;
  35. /**
  36. * Indicates if this key was just released.
  37. */
  38. this.justReleased = false;
  39. }
  40. Key.DOWN = -1;
  41. Key.UP = 1;
  42. Key.RESET = 0;
  43. Key.prototype.constructor = Key;
  44. /**
  45. * Update Key status based on new key state.
  46. */
  47. Key.prototype.update = function(action)
  48. {
  49. this.justPressed = false;
  50. this.justReleased = false;
  51. if(action === Key.DOWN)
  52. {
  53. if(this.pressed === false)
  54. {
  55. this.justPressed = true;
  56. }
  57. this.pressed = true;
  58. }
  59. else if(action === Key.UP)
  60. {
  61. if(this.pressed)
  62. {
  63. this.justReleased = true;
  64. }
  65. this.pressed = false;
  66. }
  67. else if(action === Key.RESET)
  68. {
  69. this.justReleased = false;
  70. this.justPressed = false;
  71. }
  72. };
  73. /**
  74. * Set this key attributes manually.
  75. */
  76. Key.prototype.set = function(justPressed, pressed, justReleased)
  77. {
  78. this.justPressed = justPressed;
  79. this.pressed = pressed;
  80. this.justReleased = justReleased;
  81. };
  82. /**
  83. * Reset key to default values.
  84. */
  85. Key.prototype.reset = function()
  86. {
  87. this.justPressed = false;
  88. this.pressed = false;
  89. this.justReleased = false;
  90. };
  91. export {Key};
  92. </code></pre>
  93. </article>
  94. </section>
  95. </div>
  96. <nav>
  97. <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="BezierCurve.html">BezierCurve</a></li><li><a href="Box.html">Box</a></li><li><a href="Box2.html">Box2</a></li><li><a href="BoxMask.html">BoxMask</a></li><li><a href="Circle.html">Circle</a></li><li><a href="DOM.html">DOM</a></li><li><a href="EventManager.html">EventManager</a></li><li><a href="Graph.html">Graph</a></li><li><a href="Helpers.html">Helpers</a></li><li><a href="Image.html">Image</a></li><li><a href="Key.html">Key</a></li><li><a href="Line.html">Line</a></li><li><a href="Mask.html">Mask</a></li><li><a href="Matrix.html">Matrix</a></li><li><a href="Object2D.html">Object2D</a></li><li><a href="Pattern.html">Pattern</a></li><li><a href="Pointer.html">Pointer</a></li><li><a href="Renderer.html">Renderer</a></li><li><a href="Text.html">Text</a></li><li><a href="UUID.html">UUID</a></li><li><a href="Vector2.html">Vector2</a></li><li><a href="Viewport.html">Viewport</a></li><li><a href="ViewportControls.html">ViewportControls</a></li></ul>
  98. </nav>
  99. <br class="clear">
  100. <footer>
  101. Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.2</a> on Thu Jun 13 2019 09:46:06 GMT+0100 (Western European Summer Time)
  102. </footer>
  103. <script> prettyPrint(); </script>
  104. <script src="scripts/linenumber.js"> </script>
  105. </body>
  106. </html>