Added a keymat_t version to cast it safely