Enable/disable buttons

Is it possible to enable/disable buttons based on whether a device is on/off? This moment when the device is off, buttons like mute are still pressable but do nothing.