int i, idx, cnt = 0, diff_keys = 0;
int i, idx, cnt = 0, repeat_keys = 0;
double typing_rate(double time_window, int *repeating) {	double dt = 1.0, now = dnow();	KeySym key = NoSymbol;	int i, idx, cnt = 0, diff_keys = 0;	if (key_history_idx == -1) {		if (repeating) {			*repeating = 0;		}		return 0.0;	}	if (time_window > 0.0) {		dt = time_window;	}	for (i=0; i<KEY_HIST; i++) {		idx = key_history_idx - i;		if (idx < 0) {			idx += KEY_HIST;		}		if (! key_history[idx].down) {			continue;		}		if (now > key_history[idx].time + dt) {			break;		}		cnt++;		if (key != NoSymbol && key != key_history[idx].sym) {			diff_keys++;		}		key = key_history[idx].sym;	}	if (repeating) {		if (! diff_keys && cnt > 4) {			*repeating = 1;		} else {			*repeating = 0;		}	}	/*	 * n.b. keyrate could seem very high with libvncserver buffering them	 * so avoid using small dt.	 */	return ((double) cnt)/dt;}