AFAIK, keys are not supported in ROS 2, technically RMW. There has been some discussions brought up occasionally, but i do not know any development for this feature support.

referring to @gavanderhoorn 's comment above, which is 4 years old… :old_key:

We do support content-based subscriptions, depends on RMW implementation.

https://docs.ros.org/en/rolling/Tutorials/Demos/Content-Filtering-Subscription.html

using keys would bring more high-performance efficiency for filtering process since data object is distinguished by keys individually. i am not sure about your use case or requirement, but hope this could help.