fix key_gen with kw