Guest User

XGD_KeyPress

a guest
Jan 14th, 2016
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*:
  2.  * @plugindesc Plugin for kanji illustrator. key press induces a common event
  3.  * @version 1.0
  4.  
  5. @param Key A
  6. @desc The common event to play when A is pressed.
  7. Use 0 to have that not trigger a common event.
  8. @default 0
  9.  
  10. @param Key B
  11. @desc The common event to play when B is pressed.
  12. Use 0 to have that not trigger a common event.
  13. @default 0
  14.  
  15. @param Key K
  16. @desc The common event to play when K is pressed.
  17. Use 0 to have that not trigger a common event.
  18. @default 0
  19.  
  20.  */
  21.  
  22. //Name this file XGD_KeyPress.js
  23. var parameters = PluginManager.parameters('XGD_KeyPress');
  24.  
  25. (function ($) {
  26.    
  27.     var XGD_PluginEvent = Input._onKeyUp;
  28.     Input._onKeyUp = function(event) {
  29.         XGD_PluginEvent.call(this, event);     
  30.        
  31.         switch (event.keyCode)
  32.         {
  33.             case 65: PerformCommonEvent('Key A'); break;
  34.             case 66: PerformCommonEvent('Key B'); break;
  35.             case 75: PerformCommonEvent('Key K'); break;
  36.         }
  37.     };
  38.  
  39.     PerformCommonEvent = function(p) {
  40.         var e = Number(parameters[p] || 0);
  41.         if (e !== 0)
  42.             $gameTemp.reserveCommonEvent(e);
  43.     }
  44. })();
Advertisement
Add Comment
Please, Sign In to add comment