1.  
  2. const ESC_KEY = 27;
  3. const nameInput = document.getElementById('name') as HTMLInputElement;
  4.  
  5. const subscription = fromEvent(nameInput, 'keydown')
  6. .subscribe((e: KeyboardEvent) => {
  7. if (e.keyCode === ESC_KEY) {
  8. nameInput.value = '';
  9. }
  10. });
  11.