Yes, what you want is provided by Synergy which is free and supported by donation.
You run the software on two or more computers which are close to each other, and as you move the mouse off of one screen, it jumps onto the next screen. Also the keyboard controls the computer where the mouse is currently.
It works on Windows, Mac, and Linux.
Mouse without Borders is a product that makes you the captain of your
computer fleet by allowing you to control up to four computers from a
single mouse and keyboard. This means that with Mouse without Borders
you can copy text or drag and drop files across computers.
It is only for Windows.