I only just now realized that the arguments tab in the item editor also applies to the pickup script, as well as the use script? Dur.

Of course, to use your script, you would need a separate item for every level for which you want to give a key.