title: How can I set focus always on input in Angular
body: <p>I want to control my application JUST from one text input, so I need to have focus ALWAYS on it (to prevent users from accidentally losing this focus by clicking somewhere on page etc.). And to be fair I don't even know how can I do this.</p>
  
  <p>I tried to use html's autofocus on this input and then check if it loses it's focus. But I don't know, how to "revive" this focus on it. This is my code:</p>
  
  <p>HTML file:</p>
  
  <pre><code>&lt;div fxLayout fxLayoutAlign="center"&gt;
    &lt;div fxFlex="80" class="operations"&gt;
  
      &lt;div class="H-opt"&gt;Użytkownik: &lt;span&gt;{{ActualUser}}&lt;/span&gt;&lt;/div&gt;
      &lt;div class="H-opt"&gt;Magazyn źródłowy: &lt;span&gt;&lt;/span&gt;&lt;/div&gt;
      &lt;div class="H-opt"&gt;Magazyn docelowy: &lt;span&gt;&lt;/span&gt;&lt;/div&gt;
  
      &lt;input matInput [(ngModel)]="codeExec" (focusout)="reviveFocus()" (keyup.enter)="execAction($event.target.value)" autofocus &gt;
  
    &lt;/div&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>TS file:</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { AuthService } from '../../../shared/services/auth.service';
  import { DatabaseService } from '../../../shared/services/database.service';
  import { MatSnackBar, MatDialog } from '@angular/material';
  
  @Component({
    selector: 'app-cbisgate-userdash',
    templateUrl: './cbisgate-userdash.component.html',
    styleUrls: ['./cbisgate-userdash.component.css']
  })
  export class CbisgateUserdashComponent implements OnInit {
  
    constructor(public dialog: MatDialog, private authService: AuthService, private databaseService: DatabaseService, public snackBar: MatSnackBar) { }
  
    codeExec: string = "";
  
    ActualUser;
    DepotFrom;
    DepotTo;
  
    clearCodeExec() {
      this.codeExec = "";
    }
  
    reviveFocus() {
      console.log("I'm trying to revive this input!");
    }
  
    execAction(code) {
      this.ActualUser = code;
      console.log(code);
      this.clearCodeExec();
    }
  
    ngOnInit() {
    }
  
  }
  </code></pre>
  
  <p>How can I use this reviveFocus function, is there any way to make focus again on this input? Or it's other way to do the "all-time" focus?</p>