Use the keys operator to return map keys or array indices.
keys
Given a sample.yml file of:
dog: woofcat: meow
then
yq eval 'keys' sample.yml
will output
- dog- cat
- apple- banana
- 0- 1