When the key of a channel is set to a single star (*) using +k *, the value returned by $chan().key is $null instead of containing the key. Multiple stars work however (** and so on.)
On some networks * is provided by the server when a key is set but the user doesn't have authorisation to see what it is. There's no way for mIRC to tell the difference between when it represents a literal * and when it represents a hidden key.