How to save current input.value while typing, into a new global variable?

how do i save the input.value while typing into a new variable(currentInput) so that i can use that new variable globally?

HTML code:
    <h1>Check if your text is a Palindrome:</h1>
    <div id="palindrome-checker">
      <p>Enter your text</p>
      <form id="palindrome-form">
        <input type="text" id="text-input" required value="">
        <button type="button" id="check-btn" >Enter</button>
      </form>

Javascript code:     
   const input = document.querySelector("#text-input");
   const button = document.querySelector("#check-btn");
   const output = document.querySelector("#result");
   const form  = document.querySelector("#palindrome-form");
   let currentInput = "";

   
   input.onkeyup = myFunction

  function myFunction(){
  currentInput = document.querySelector("#text-input").value 
  }