Couldn't get your example working either, so I've done it a bit different way:
Code:
#define KEY_TYPE_NONE					0
#define KEY_TYPE_HOLD					1

var key_type = 0;

function get_key_hold(var *input, var *key){
	
	var counter = 0, def_time = 0.5;
	
	while(counter <= def_time){
		
		if(*key == 0){ counter = 0; break; }
		counter += time_frame / 16;
		wait(1);
		
	}
	
	if(counter >= def_time){ *input = KEY_TYPE_HOLD; }
	return(*input);
}

function test(){
	
	get_key_hold(&key_type, &mouse_left);
	
}

function main() {
	
	warn_level = 6;

	fps_max = 60;
	fps_min = 30;
	time_smooth = 0.9;
	
	on_mouse_left = test;
	
	while(1){
		
		DEBUG_VAR(key_type, 10);
		
		if(key_type == KEY_TYPE_HOLD){
			
			beep();
			key_type = KEY_TYPE_NONE;
			
		}
		
		wait(1);
	}	
}



Also 'time_frame' is better for counters/timers (thanks to Superku).
I found out that you example get's messed up cause of the while loop, if I removed it, I could get -1...
This is weird to me, probably cause of my lack of knowledge I guess. grin


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung