Type Rate Function by RiiDii19th Jan 2005 0:39
|
---|
Summary Type Rate Function that slows down the input of the Inkey$() function. Description Using the Inkey$() results in fast key repeat. This function checks the Inkey$() for new values at the same high-rate of speed, but slows down the repeat cycle. It also does not require any variables be established outside of the function (ie. Dim statements). Can anyone help do this effectively without using the clipboard? Code ` This code was downloaded from The Game Creators ` It is reproduced here with full permission ` http://www.thegamecreators.com ` Sample type-rate function call program sync on : sync rate 0 TypeRate = 1000 : Rem 1 second delay Do i$ = GetAKey(TypeRate) set cursor 0,0 if i$<>"" i2$=i2$+i$ Print i2$ endif sync loop ` The function is the real meat-and-potatoes. Function GetAKey(DelayValue) Rem DelayValue = milliseconds (1000 = 1 second) GetAKey1$="" temp$=Get Clipboard$() if len(temp$)>0 LastKey$ = Left$(temp$,1) LastTime$ =Right$(temp$,len(temp$)-1) LastTime=Val(LastTime$) else LastKey$="" LastTime=Timer() Endif a$=inkey$() if a$=LastKey$ if LastTime+DelayValue<Timer() GetAKey1$=a$ NewSave$=a$ + Str$(Timer()) Else GetAKey1$="" NewSave$=LastKey$ + str$(LastTime) Endif else if len(a$)>0 GetAKey1$=a$ NewSave$=a$ + Str$(Timer()) else GetAKey1$="" NewSave$="" endif endif Write To Clipboard NewSave$ EndFunction GetAKey1$ |