ConnectionBasedLink extends AbstractListenerLink { @Override public long sendKeyPressEvent(char keychar, int keycode, int keylocation, int keymodifiers, int keymodifiersex) throws IOException { ToDeviceMessageKeyPress msg; synchronized (connection) { msg = addMessageIdIfNeeded( new DefaultToDeviceMessageKeyPress(keychar, keycode, keylocation, keymodifiers, keymodifiersex)); send(this.protocol.toDevice(msg)); } return messageIdOf(msg); } ConnectionBasedLink(Connection connection, Protocol protocol); Connection getConnection(); Protocol getProtocol(); boolean waitForArduinoToBoot(int wait, TimeUnit timeUnit); boolean waitForArduinoToBoot(int wait, TimeUnit timeUnit, final Mode mode); @Override long startListening(Pin pin); @Override long stopListening(Pin pin); @Override long switchAnalogPin(AnalogPin analogPin, int value); @Override long switchDigitalPin(DigitalPin digitalPin, boolean value); @Override long sendKeyPressEvent(char keychar, int keycode, int keylocation, int keymodifiers, int keymodifiersex); @Override long sendTone(Tone tone); @Override long sendNoTone(AnalogPin analogPin); @Override long sendCustomMessage(String... messages); @Override void close();  }
@Test public void canSendKbdEvents() throws IOException { this.link.sendKeyPressEvent('#', 1, 2, 3, 4); assertThat(toArduinoWasSent(), is("alp: }