This is the world’s shortest whitepaper showing how to use javascript to record keystrokes and log them.
You can download it from the following link: https://packetstormsecurity.com/files/download/152048/xss-keylogger.pdf
Source: https://packetstormsecurity.com/files/152048/How-Do-You-Use-An-XSS-As-A-Keylogger.html