You can try to check the weapon ID after the KEY_FIRE is released. (It should work.)
This is still no different to the example I provided in the OP. You can still switch weapons before the grenade is actually thrown. In this case, it doesn't matter if the key is pressed or released.