If you are interested in learning about keyloggers for security purposes, it is recommended to use legitimate educational resources or sandboxed environments like TryHackMe or Hack The Box. Index of /keylogger
I can provide more technical details on this topic if you tell me: index of keylogger