Have you considered having the player click a chest for this mini-game? They can still have to be near it, but that would save you a lot of hassle I would think.
Simple rectangle for a detector - if it's over a chest, they may click it. If it is over more than 1 chest, they may click either one, giving the player the choice.
Or if you want to keep it entirely to keyboard, you could also use keys (such as 1 and 2) for when two chests are available.
I may be going off track here, but I thought I'd check.