How can I assign digital product keys for a free copy of the software?

We have a digital product, having a digital product key (license code).
We uploaded a large number of keys, and when the product is purchased (using a credit card) the digital product key gets assigned. I can even see what contact have which particular keys.

Software license codes (digital product keys) reside in the contact record in the custom field: ~DigitalProductKeys_2_KeyMusician Keyboard~
but I cannot see any way of viewing or setting this field.

However, when I give away a free copy (and no credit card is involved), no digital product key is assigned to that contact, and I have to manually assign a digital product key.

How can I make the assignment of digital product keys to a contact, automatic, without the use of a credit card?