Solution 1:

you could create a scoreboard objective that checks if a person has the key card and the command would go like this. First, in an impulse command block /scoreboard objectives add KeyCard dummy activate it and it will add a scoreboard objective called keycard. Now put this command in a repeating always active command block. Put in this command in the command block /testfor @a[score_KeyCard_min=1,r=3]

then add a comparator and repeator to look like this it will normally be off unless a player is within a 3 block radius with a score of one keycard.enter image description here

now add two impulse commands one command will have this command init

/scoreboard players add @p KeyCard 1 this will add 1 keycard to the nearest player

and in the next command

/scoreboard players remove @p KeyCard 1

just in case if you want to take the keycard away.

the testfor command (the one in the picture) will create a Redstone current if you have a Keycard score of 1 and are within a 3 block radius which you could hook up to an iron door.

Good luck

CreepedOutNizo,