Hello.
The only way you lose your key nowdays is if you accidentally retreat from battle (quitting a game, losing connection and any sort of forcibly closing the app does not consume key). This change has been on for quite a while, namely your keys are only spent AFTER the battle credits.