The license is the key, the key is the license, you are confused.
No clue why you are using the term license.
No you can`t keep it, there`s nothing to keep'
You have to install 7 SP1, 8 or 8.1 and upgrade to 10 for free from that on the new hardware or just buy Windows 10 Retail, end of story.
Make sure you tell a potential customer how you arrived at Windows 10 when you sell the PC, it`s just good etiquette
If you don`t have an Operating System to put on the PC you want to sell, then just leave Windows 10 on it.
Your new PC will come with Windows, if you are building your own PC, then of course you will have to buy Windows if you don`t already own 7 or 8 or 8.1.
I'm somewhat surprised about the incorrect things that have been said in this thread.
"There is no license": That's of course completely wrong. Microsoft is the holder of the intellectual property of Windows 10. They are the only ones that are allowed to use Windows 10. Everybody who want's to use Windows 10 needs permission from MS to use it and what's the name for such a permission? Exactly, it's a license. So in order to use Windows 10 you definitely need a license, even if you upgraded from a predecessor like Windows 8.1. The only difference are the conditions that license comes with. Permission to use software (either protected or open source) = license.
"There is no license key": Wrong again, there is definitely a license key for Windows 10, even if you upgraded from an older Windows version. That key is needed if you want to install Windows 10 again (so called clean install). It can be acquired using tools like License Crawler or ProduKey by Nirsoft (which belongs to MS I think). Take a look at the following print screen which shows my license key of Windows 10 after upgrading from 8.1 (obfuscated of course).
Now back to the question of the op: I highly doubt it's possible to transfer the license of an upgraded Windows 10 to another machine. But I'd still try it. First make sure the hdds in the pc pc you want to sell are completely clean meaning Windows 10 is not installed anymore. Then I'd call MS and ask them to manually activate Windows 10 telling them something about a broken mainboard that had to be replaced. It might work but probably it wont. According to the EULA of Windows 10 upgrade it shouldn't but who knows
Returning to the original question:
If your old Windows license (7 or 8) was retail, then you could use it again on a new homebuilt PC if:
you removed the OS from the PC that you sold (or gave away)
Installed the old OS on the new PC and upgraded that to Win 10.
What happens after 29 July, 2016, when the free Win 10 upgrade offer expires, I don't know.
Incidentally, no license key is retained on a PC that has the Win 10 upgrade. Once it is installed and activated, you can scrub the hard drive, eliminating all partitions, and clean install Win 10 on the machine and have it activate online. I believe that you could use a virgin hard drive and still activate it. The "same hardware" requirement isn't that strict.