title: Java Robot and KeyEvent in MATLAB
body: <p>I have a question regarding using robot and keyevent in MATLAB</p>
  
  <pre><code>import java.awt.Robot;
  import java.awt.event.KeyEvent;
  robot = Robot;
  if isequal(eventdata.Key,'return')  % capture enter 
    robot.keyPress(KeyEvent.VK_ENTER);
    robot.delay(0.1);
    robot.keyRelease(KeyEvent.VK_ENTER);
  end
  </code></pre>
  
  <p>This block of code performs its function correctly.  However, it create an enter event outside from the form itself.  How do I contain it in the active form or gui only not in other documentation ?</p>