Also check if you are an op in the channel before removing the key.
alias rmkey {
var %chan = $iif($1,$1,$active)
if ( $me isop %chan ) && ( $chan(%chan).key ) mode %chan -k $v1
}
Syntax: /rmkey [#channel]
If channel is not entered, the active channel will be used.