Connecting two macbook pros and a windows laptop device to external monitor
Many modern Logitech keyboards, indeed many modern Bluetooth keyboards and mice include support for multiple pairings, you should check if yours do and use this, otherwise you will be limited in what swapping you can do because you'll need to disconnect and reconnect on each device and that will require trackpad/mouse input on both other devices.
The hardware solution to this is a KVM but that won't work with a Bluetooth keyboard, the software solution might work but will depend on one machine being consistently there is using something like Synergy Desktop app.