How to check if a function is null?

I tried to use this code to disable a light that appears when an in game key is pressed.

if (OnMouseDown == null) { key.light.enabled = false; }

Instead I received an
Operator ==’ cannot be applied to operands of type method group' and null'

Is there an easier way to do this, or to fix my code?

Thank you.

Functions can’t be null. Put the code in OnMouseUp instead. Although talking about pressing keys doesn’t make a lot of sense when using OnMouseDown/Up so I don’t know if that’s what you actually want.