home *** CD-ROM | disk | FTP | other *** search
- class Mkey
- {
- var nTime;
- var nDelay;
- var bHold;
- var bDouble;
- var nKey;
- var sKey;
- function Mkey(_nKey)
- {
- this.nTime = 0;
- this.nDelay = 400;
- this.bHold = false;
- this.bDouble = false;
- this.nKey = _nKey;
- this.sKey = String.fromCharCode(this.nKey).toUpperCase();
- }
- function up()
- {
- }
- function down()
- {
- }
- function hold()
- {
- }
- function unHold()
- {
- }
- function double()
- {
- }
- function move()
- {
- if(Key.isDown(this.nKey))
- {
- if(this.bHold)
- {
- this.hold();
- }
- else
- {
- this.bHold = true;
- this.down();
- if(getTimer() - this.nTime < this.nDelay)
- {
- this.double();
- this.bDouble = true;
- }
- this.nTime = getTimer();
- }
- }
- else if(this.bHold)
- {
- this.bHold = false;
- if(this.bDouble)
- {
- this.nTime = 0;
- this.bDouble = false;
- }
- this.up();
- }
- else
- {
- this.unHold();
- }
- }
- }
-