how about a for each loop that checks for a specific thing.lets say your key is an actor in this case and your inventory is an array of actors and you need 4 keys. you could have a for each loop that cast each element to the actor type key and if it succeeds then you increment a variable and if fail do nothing. then when the loop is done just check the value of the variable and it will tell you how many keys you have.
Also if you wanted this script on the door bp then all you would need to do is to cast to the player character at the start and off the cast get the inventory.
