If you use the correct version of 8.1 and do a fresh install it should install without asking for a cd key as it will pull it from the bios if it is a store bought machine.
If it isnt and you have a keycode for 8 then install 8.1 using one of these install keys, then once installed just go to activate it and click change key and it will then accept the key you have, thats how I did mine
Windows 8.1 KMS Client keys
Core: 334NH-RXG76-64THK-C7CKG-D3VPT
Professional: XHQ8N-C3MCJ-RQXB6-WCHYG-C9WKB
Enterprise: MNDGV-M6PKV-DV4DR-CYY8X-2YRXH
These keys MS list right on their site and they are used just for installing 8.1
Shane