@Override public void keyPressed(KeyEvent arg0) { if (!arg0.isActionKey()) { char c = arg0.getKeyChar(); if (c == ' ' || c == '\n') { uncommitedText += c; System.out.println("you typed the word: \"" + uncommitedText + "\""); /* * Code for communicating with PDStore here * 1. Create PDWord instance? * 2. Commit to PDStore? */ PDWord word = new PDWord(store); word.addText(uncommitedText); PDOperation op = new PDOperation(store); op.setCommand(editor.INSERT); Date date = new Date(); op.setTimeStamp(date.getTime()); op.setUser(TextEditor.userName); PDInsert insert = new PDInsert(store); insert.setWord(word); insert.setAfter(word); op.setSuperParameter(insert); history.addOperation(op); store.commit(); // this.repaint(); uncommitedText = ""; } else if (c == '\u0008') { // backspace character int i = uncommitedText.length(); uncommitedText = uncommitedText.substring(0, i - 1); } else { uncommitedText += c; } } }