getkey()
Blitz3D Forums/Blitz3D Beginners Area/getkey()| 
 | ||
| H! I'm busy with my own Input$() but now I want that people can't do this: bla bla (not multiply spaces between words) So I have this code below but now its not possible to make 1 space between words. Repeat c=GetKey() If c<>0 And c<>13 And c<>27 Then ;no 0,enter,esc If c<>32 And h<>32 Then ;no multiply spaces w$ = w$+""+Chr$(c) Write Chr$(c) EndIf EndIf h=c c=0 Until KeyHit(28) Or KeyHit(1) | 
| 
 | ||
| mmm with trying some other things its oke now. srry, can't delete/close this topic. Repeat c=GetKey() If c<>0 And c<>13 And c<>27 Then ;geen 0,enter,esc DebugLog "c"+c+" h"+h If c=32 And h=32 Then c=32 Else w$ = w$+""+Chr$(c) Write Chr$(c) EndIf h=c EndIf Until KeyHit(28) Or KeyHit(1) | 
| 
 | ||
| Not pretty, but how about this... 
Repeat
current=GetKey()
If current<>0 And current<>9 And current<>13 And current<>27 Then ;trap TAB,enter,esc
		
	If current<>32 Then 			;get any non-space chars
		w$ = w$+""+Chr$(current)
		Write Chr$(current)
		previous = current			; reset 'previous' to a valid value
	Else
		If previous <> 32 Then		; or else print/add a space
			w$ = w$+" "
			Write " "
			previous = 32			; and note that you just used one {so trap future spaces}
		EndIf
	EndIf		
EndIf
		
Until MouseHit(1)					; use mouse to escape program
End
 | 
| 
 | ||
| That's nice too, maybe I use that methode. Thanks for the TAB key :) | 
| 
 | ||
| You could also perhaps use: The 'Replace' function on the resultant string. Include this each loop while the input is being recorded. http://www.blitzbasic.com/b3ddocs/command.php?name=Replace&ref=2d_cat |