All pastes #291157 Raw Edit

Miscellany

public java v1 · immutable
#291157 ·published 2006-12-24 20:54 UTC
rendered paste body
package com.nak.bot.input;import java.awt.Component;import java.awt.event.KeyEvent;public class KeyUtilities extends InputUtilities {	public KeyUtilities(Component target) {		super(target);	}	public void typeKeys(String keys) {		for(char c : keys.toCharArray()) {			typeKey(c);		}	}	public void typeKeys(char[] keys) {		for(char c : keys) {			typeKey(c);		}	}	public void typeKey(char key) {		long when = System.currentTimeMillis();		target.dispatchEvent(new KeyEvent(target, KeyEvent.KEY_PRESSED, when, 0, key, key));		target.dispatchEvent(new KeyEvent(target, KeyEvent.KEY_TYPED, when, 0, 0, key));		target.dispatchEvent(new KeyEvent(target, KeyEvent.KEY_RELEASED, System.currentTimeMillis(), 0, key, '?'));	}}