Added keyboard.js
This commit is contained in:
		| @@ -4,6 +4,7 @@ | ||||
|     <script type="text/javascript" src="scripts/position.js"></script> | ||||
|     <script type="text/javascript" src="scripts/pointer.js"></script> | ||||
|     <script type="text/javascript" src="scripts/brush.js"></script> | ||||
|     <script type="text/javascript" src="scripts/keyboard.js"></script> | ||||
|   </head> | ||||
|   <body> | ||||
|     <canvas id="myCanvas" width="1280" height="800" style="background:#efefef"></canvas> | ||||
|   | ||||
							
								
								
									
										54
									
								
								scripts/keyboard.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								scripts/keyboard.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | ||||
| function Keyboard() | ||||
| { | ||||
|   this.is_locked = false; | ||||
|  | ||||
|   this.lock = function() | ||||
|   { | ||||
|     this.is_locked = true; | ||||
|     interface.actions_panel.style.color = "red"; | ||||
|   } | ||||
|  | ||||
|   this.unlock = function() | ||||
|   { | ||||
|     this.is_locked = false; | ||||
|     interface.actions_panel.style.color = "black"; | ||||
|   } | ||||
|  | ||||
|   this.listen = function(event) | ||||
|   { | ||||
|     if(this.is_locked === true){ return; } | ||||
|     switch (event.keyCode) | ||||
|     { | ||||
|       case 13: this.key_enter(); break; | ||||
|       case 32: this.key_space(); break; | ||||
|       case 38: this.key_arrow_up(); break; | ||||
|       case 40: this.key_arrow_down(); break; | ||||
|       case 37: this.key_arrow_left(); break; | ||||
|       case 39: this.key_arrow_right(); break; | ||||
|     } | ||||
|   }; | ||||
|  | ||||
|   this.key_enter = function() | ||||
|   { | ||||
|   } | ||||
|  | ||||
|   this.key_space = function() | ||||
|   { | ||||
|   } | ||||
|  | ||||
|   this.key_arrow_up = function() | ||||
|   { | ||||
|   } | ||||
|  | ||||
|   this.key_arrow_down = function() | ||||
|   { | ||||
|   } | ||||
|  | ||||
|   this.key_arrow_left = function() | ||||
|   { | ||||
|   } | ||||
|  | ||||
|   this.key_arrow_right = function() | ||||
|   { | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user