Newcastle, who have fellow strugglers Birmingham, Fulham and Reading in their next four games, were hanging on until a freak Jermaine Pennant goal two minutes from the break, with Fernando Torres doubling the lead a minute later and Steven Gerrard wrapping up the scoring in the 51st minute.
Keegan said: "Their first goal was a freak, and maybe we needed something like that rather than them. That's what happens when you are struggling.
"From then on it was always going to be tough, two down to Liverpool at Anfield means they can relax and play their football.
"But our players are a tight-knit group and we all believe we have the ability and quality to stay in this division.
"We are very confident of that. You need 40 points to stay up and we need four wins to do that. We will do it."