A keylogger is a software or method for tracking and collecting what you type on a keyboard, usually without your knowledge. To prevent the collection and transmission of this data, you need to turn off two separate options in Windows 10’s Privacy settings.
  • Click or tap the Start button, and choose Settings.
         
  • In the Settings window, scroll down and click or tap Privacy.
         
  • In the Privacy settings, click or tap General in the left navigation. Under Change privacy options, find the section that says, Send Microsoft info about how I write to help us improve typing and writing in the future. Click or tap the On button to slide it to the Off position.
         
  • Next, while remaining in the Privacy settings, click or tap Speech, inking, & typing in the left navigation. Under the Getting to know you section, and click or tap the Stop getting to know me button.
         

As it states, dictation and the Cortana personal assistant functions will no longer work if you want Microsoft to stop getting to know you. However, now that you know how to disable the Windows 10 keylogger, you can simply toggle it on and off as needed. Each time you choose Stop getting to know me, the collected data is cleared from your device.

Source: 
https://techhelpkb.com/how-to-disable-the-windows-10-keylogger/