The Labour leader was speaking on a visit to a medical research hub in Edinburgh's BioQuarter, where he pledged his party's industrial strategy would make Scotland a "world leader" in medical technology.
Sir Keir told Representing Border he would work constructively with whoever becomes the next SNP leader and First Minister.
However, he said they were "operating in a parallel universe" if they thought Labour would do a deal with the SNP after the next General Election.
In particular, the Labour leader said he would not consent to another independence referendum, "no ifs, no buts".
The SNP leadership contest has become increasingly divided, with all three candidates asking the party to release its membership numbers.
Previous estimates put the membership at 104,000 in December 2021, although reports suggest 78,000 online ballot papers have been sent out in the current leadership election.
The campaigns of Kate Forbes and Ash Regan have called for independent auditors to be brought in to offer assurances to SNP members and the public.
But Humza Yousaf - widely viewed as the favourite for the top job among the party hierarchy - has said he has confidence in the election process.
Want a quick and expert briefing on the biggest news stories? Listen to our latest podcasts to find out What You Need To Know...