When you say:
When the cable of the keyboard is not connected the laptop is working properly.
Do you mean that you have opened the laptop, removed the keyboard cable and have attached an external (usb) keyboard to test this?
If so, you've already done most of the heavy lifting in replacing it.
The only alternative is to replace the keyboard cable (if that's an option) and to make sure the internal circuits of the keyboard are clean. (that's usually not as easy since most keyboards are sealed in such a manner that can easily get damaged if not opened right)
I would personally just replace the keyboard if you're sure that's where the issue lies. fixing the old one can be really hard and time consuming and depending on any damage on the circuits, turn into a lost cause.