Despite an extensive search of official records, no reference to Keogh performing such duties could be found - in fact, it is recorded that Lincoln returned to Washington by train from Frederick, Maryland directly back to the capitol. However, as seems to be the case with Luce's novel, there is some truth in what was first published in 1939.
According to Lincoln's official records, as found on the excellent http://www.thelincolnlog.org/, the following is an account of his visit to the Army of the Potomac;
Wednesday, October 1, 1862 at 6a.m. -- The President and his party left Washington on a special train to visit the headquarters of the Army of Potomac and battlefields in vicinity of Antietam. The party consists of General McClernand, Capt. Wright Rives of McClernand's staff, Marshal Lamon, Ozias M. Hatch (Illinois politician), John W. Garrett, president of B. & O. Railroad, and others. The train arrived Harper's Ferry at noon. Major Lawrence Kip and Captain Samuel S. Sumner escorted the President and his associates to General Sumner's headquarters. In afternoon General McClellan arrives from camp and with President reviews troops at Bolivar Heights. Lincoln spends night in Harper's Ferry.
Thursday, October 2, 1862 -- In the morning, Lincoln and General Sumner reviewed the troops at Loudoun Heights and Maryland Heights. President leaves Harper's Ferry at noon. Arrives headquarters, Army of Potomac, too late in day to review troops. Occupies tent for night next to Gen. McClellan's headquarters. Second Cavalry band serenades President.
Friday, October 3, 1862 -- At sunrise President and O. M. Hatch walk to nearby hilltop. Surveying army camp, Lincoln comments: "This is General McClellan's bodyguard." During morning, Lincoln reviews General Burnside's corps and cavalry near Antietam battleground. At midday, the President and McClellan ride in ambulances three miles to Bakerville, Md., for review of cavalry and troops of Gen. Fitz John Porter's and Gen. Franklin's corps. On the three-mile ride, Marshal Lamon sings several comic ballads [which later result in much public criticism of President]. Lincoln poses for half-dozen group pictures. Again sleeps in tent next to McClellan's headquarters.
Saturday, October 4, 1862 -- President Lincoln and Gen. McClellan (pictured above during visit) visit wounded in vicinity of headquarters. At Sharpsburg, Md., (Antietam) Lincoln visits "Fighting Dick" (Gen. Israel B.) Richardson who lies mortally wounded in farmhouse. At noon, they ride to South Mountain battleground and conclude their survey. Enthusiastic reception with signal guns and parade welcomes President to Frederick about 4:45 P.M. He goes to residence of Mrs. Ramsey to see Gen. George L. Hartsuff who is ill from wounds received at Antietam. Addresses brief remarks to crowd assembled in front of house. About five minutes later speaks to crowd at railway station (illustrated below in Harper's Weekly 1862):
"FELLOW-CITIZENS: I see myself surrounded by soldiers, and a little further off I note the citizens of this good city of Frederick, anxious to hear something from me. I can only say, as I did five minutes ago, it is not proper for me to make speeches in my present position. I return thanks to our soldiers for the good service they have rendered, for the energies they have shown, the hardships they have endured, and the blood they have so nobly shed for this dear Union of ours; and I also return thanks not only to the soldiers, but to the good citizens of Maryland, and to all the good men and women in this land, for their devotion to our glorious cause. I say this without any malice in my heart to those who have done otherwise. May our children and our children's children to a thousand generations, continue to enjoy the benefits conferred upon us by a united country, and have cause yet to rejoice under those glorious institutions bequeathed us by Washington and his compeers. Now, my friends, soldiers and citizens, I can only say once more, farewell."
At 10 P.M. special train bearing Presidential party arrives in Washington.
-------------------------Above is the official record of the visit and it is highly probable that Captain Myles Keogh, as a member of staff, accompanied General McClellan for some, if not all his time, with President Lincoln -- the President toured the battlefield with 'Little Mac' as his guide.
According to 'The Antietam Campaign' by Gary W. Gallagher, Lincoln was less attentive of his host when shown the battlefield HQ at the Pry house near Antietam on the second day of the visit, October 2nd. When the President finally said - "Let us go and see where Hooker went in" - McClellan could only but gather that Lincoln wanted to see the where a 'fighting' general performed his duty. Later, when McClellan and his staff arrived at the union right flank, the President was nowhere to be seen. Apparently, McClellan "dispatched one staff officer after another to find the errant chief executive" without success. Was Captain Keogh part of that search party?
One can only presume that Keogh did indeed spend some time in the presence of the iconic Abraham Lincoln, although if he had developed some loyalty to McClellan during his short stint on his staff, Myles may not have been too endeared at being in the President's company. Lincoln was losing his patience with McClellan at the time and the atmosphere during the visit must have been tense -- likely given Lincoln's comment on the Army before him being "General McClellan's bodyguard".
Regardless, Lincoln was to be proven correct by history and has become one of America's most famous and admired presidents. In later years, one can only wonder what Keogh's recollections were of those four days in 'Abe's' presence - not a bad memory for a young man from a small town in Ireland...