title: How can I set focus to another input?
body: <p>I need to be able to switch focus to an input element when some event occurs. How do I do that in Angular 2?</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;input (keyUp)="processKeyUp($event)"/&gt;
  &lt;input (focusme)="alert('i am focused')"/&gt;
  </code></pre>
  
  <p>I want to focus the 2nd input box when a certain key is pressed in the first. I think I need to use a custom event (<code>focusme</code> in the snippet), but I don't know where or how to declare it, and whether to use a <code>@Directive</code> annotation for it, or include its definition in a component somehow. In short, I am stumped.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Forgot to mention, I know I can do that by using local variables in the html, but I want to be able to do it from the component, and I want to be able to do complex logic when firing the <code>focusme</code> event so that controls listening to it can determine if it is meant for them or not.
  Thanks!</p>