Keegan was in charge at St James Park for five years and took them from Division One strugglers to the top of the Premiership before stepping down.
Arsenal, who after beating Liverpool 1-0 are tipped to win the cup this year, have an easier draw in the fifth round, against Gillingham or Bristol Rovers at home.
Only one all-Premiership tie
Only one tie is between two teams from the Premiership, with Blackburn Rovers at home the reward for Middlesbrough's win against Manchester United.
Giant killers Tranmere Rovers await the winners of the fourth round tie between Tottenham Hotspur and Bolton Wanderers, while the winner of Chelsea and West Ham's replay will play Preston North End.
Everton will play Crewe, Fulham travel to Walsall and West Brom play Cheltenham - ensuring at least one quarter finalist will be from outside the Premiership.