To quote Charles Ross, Richard's seizure of the crown took place "in an atmosphere of rumour, suspicion, propaganda exercises, plot and counter-plot. Only those in the centre could be fully aware of what was going on. . ." Ross points to this question in particular as one where there is much uncertainty.
Richard probably did not aim to take the throne before his brother's death. Suggestions that his plans were so long established are taking too credulously the Tudor version of events. There is no way Richard could have anticipated Edward IV's untimely death. Some scholars have suggested that he made the decision to usurp the throne when he seized Edward V at Stony Stratford. A date that has been favoured is the 13th of June, the date of execution of Lord Hastings, an important supporter of Edward IV. It might even have been later than this, tied either to a realisation that, with the drastic step of Hastings' execution taken, his best option was to go all the way and take the throne. Or it might have been tied to the realisation that the only way to take the wind out of his enemies' sails was to eliminate the threat posed by Edward V.
The power struggle after the death of Edward IV was initiated by the Woodvilles. Their aims were to take control of the treasury, put a fleet at sea, bring Edward V to London with an army led by Earl Rivers and have the boy king crowned as soon as possible. Then they would set up a regency dominated by the Woodvilles and their allies. In order to achieve this the Woodvilles needed to control the royal council.
The royal council was dominated by men who had been absolutely loyal to Edward IV and could therefore be expected to transfer that loyalty to his son. Edward IV had chosen Richard, duke of Gloucester (the future Richard III) to be regent following his death, however it was entirely possible that the council would ignore this, as they had with the previous duke of Gloucester in 1422. The Woodvilles had some early success in co-opting the council - they had an early coronation approved and they settled on a regency council, of which Gloucester would be a member, but wouldn't allow him to exercise a full regency. However this was the limit of their success - Lord Hastings put his foot down on the issue of that Woodville army that was supposed to come with the king, likely fearing a Woodville ascendancy as much as anything else.
However, Gloucester moved faster than anybody expected. On the 30th of April news reached London that he had taken control of the young king and arrested Earl Rivers and key members of the Woodville faction. It is ambiguous who Edward IV had intended to have control of the young king (which was not necessarily the same as controlling the government); it may have been Gloucester, it may have been Earl Rivers (who had been the boy's governor whilst Edward was alive). It is entirely possible that Richard genuinely feared for his life if the Woodvilles were successful in controlling the king's regency - it would not have been without precedent, his brother the Duke of Clarence having been killed just five years previously. There's nothing to suggest that Richard was aiming for the throne at this point - his actions here can be firmly explained within the context of the struggle for the regency. He still had options.
At this point rumours that Richard planned to usurp the throne did begin to swirl. He moved to try and squelch them and re-assure the council of his good intentions, but the rumours refused to subside and his reputation took the first of its many beatings. In the wake of this the Woodvilles ran to the hills. The dowager queen, Elizabeth Woodville, took refuge in Westminster abbey with her other children including, crucially, Richard, duke of York, Edward V's heir apparent.
The next few weeks following Richard's capture of the king are not well attested. He entered London on the 4th of May (the date the Woodville backed coronation had been planned for). A new date for the coronation was fixed on the 22nd of June and Richard was confirmed in his role as Protector of the Realm. However, his arrest of Earl Rivers and the others of the Woodville faction was not supported in the council. Richard's primary goal at this point would be to secure his power in the long term - his Protectorship would expire at Edward V's coronation and his aim was to have it extended beyond that. However at this stage, in early May, it seems unlikely that he was as of yet planning usurpation. He was careful to cultivate support amongst Edward IV's household and allies, with the exception of the Woodvilles.
By the end of May many of Richard's contemporaries believed that he planned to usurp the throne, including our contemporary chroniclers, who are very well informed. It seems as though Richard's continued detention of the Woodvilles, the king's relatives, as well as his failure to provide for the Queen are what aroused the suspicions of his contemporaries at this stage. There is no compelling reason to dismiss their testimony and it is entirely likely that Richard had designs on the throne by the end of May.
As previously mentioned, a major stumbling block for Richard was the Queen and specifically her custody of the Duke of York. If Richard was (increasingly plausibly) plotting to take the throne then having the heir presumptive in custody was a necessity. If he still intended to support Edward V then having the heir missing at the coronation would be a major political embarrassment, especially with Richard planning to continue running the government - it would signal to everybody that he was exercising regency in opposition to the wider royal family. However, the decisive moment came on the 13th of June, with the arrest and execution of Lord Hastings and the purge of those councillors who for the sake of convenience I am going to refer to as 'Edwardians'.
Richard's break with Lord Hastings is an important moment in revealing his intentions. Hastings was one of the most important of those councillors whose loyalty was closely tied to the deceased Edward IV. He had backed Richard at critical moments. Richard turning his back on Hastings is a clear indication that he was preparing to take steps that the Edwardian faction would have found unacceptable - his own coronation as king. In my opinion, the days leading up to Hastings murder are the absolute latest Richard can have decided to seize the throne. If Richard were still merely planning to shore up his regency then Hastings was hardly an enemy in waiting; he had no reason to move against him unless he sought the throne. Certainly Richard's allegations that Hastings was conspiring with the Woodvilles are incredibly thin, especially given how decisively Hastings had moved against them early on. It is possible that Hastings had become suspicious that Richard had usurpation in mind and begun to move against him, but if this was the case, then Hastings was probably not wrong at this stage. Contemporary sources, however, suggest that Hastings was taken by surprise by Richard's betrayal, and I think we should take this testimony seriously. It is worth noting that Hastings' execution was incredibly unpopular and did more damage to Richard's increasingly battered reputation.
Following Hastings' murder Richard moved quickly. With the council now cowed he successively moved to secure the custody of the Duke of York. This is the last possible moment where Richard can have made up his mind (though, as I said, I think he began aiming for the throne some time between the 20th of May and the 13th of June). The dissatisfaction with him at this point, in the wake of Hastings' murder would have led him to conclude that taking the throne was necessary to his political survival. With York in hand he cancelled the parliament scheduled for the 25th of June as well as preparations for Edward V's coronation. The Earl Rivers was executed and the young king's attendants were withdrawn. The princes were taken to the inner apartments of the tower of London and began to be seen less, and less frequently, until they were seen not at all.
On the 22nd of June Richard's official mouthpieces began to set out his claims to the throne in speeches, sermons and a pseudo-parliament. The most famous framing of his claims came in a parliament called in 1484. Richard attacked Edward IV's government, arguing that it had been so immoral and corrupt as to damage the country. He attacked the legitimacy of Edward IV and his marriage to Elizabeth Woodville. These claims were all pretty thin, though this is one of those things we'll be arguing about until the end of time. The reality was that Richard's claim was backed by force.
So, there you go. Richard likely didn't immediately start plotting to take the throne after Edward IV's death, but likely made his mind up in late May/early June and was almost certainly on that course when he moved against Lord Hastings on the 13th of June.