Cats naturally seem to gravitate towards a keyboard whenever you’re trying to use a computer. While laptop keyboards in particular can be warm and enticing to a cat, heat is actually the least likely reason why your cat prefers to sprawl across your keyboard.
The real reason is that cats want attention. Since they see you staring at a screen and touching a keyboard, cats naturally figure if they can get in between your screen and keyboard, you’ll be forced to pay more attention to them.
Once you start petting or paying attention to the cat, you’ve set up a self-reinforcing cycle that encourages the cat to lay on your keyboard once more. See how cats are training you without you even knowing it?