Is there an easy way to transform an object into an array of it’s keys strings?

I want to make an function (or find one that does it for me) that gets an object keys and puts them into an array, like paths for the values, here an example:

const obj = {
    key1: 'a',
    key2: 'b',
    key3: {
        subkey1: 'value',
        subkey2: {
            subsubkey: 'value'
        }
    }
}

console.log(functionThatIWant(obj))

And I get this return:

[ 'key1', 'key2', 'key3.subkey1', 'key3.subkey2.subsubkey' ]

I tried find a funcion like this somewhere and I couldn’t, and I’m trying to make it by my own (It’s not working)