Puerto Rico's latest round of violence caught Gov. Carlos Romero Barcelo on a political shopping trip in Washington, but it only helped him underline his message.

He went to let both President Carter and Sen. Edward M. Kennedy (D-Mass.) know, according to politicians here, that Puerto Rico needs personal attention now and promises of the same after 1980. In return, Romero's New Progressive Party can probably deliver at least half of Puerto Rico's 41 Democratic Party convention votes in the island's March 16 primary.

Kennedy can already count on about half of the delegates here, political observers say. But how the other half goes depends on whether Romero decides to endorse Kennedy or Carter.

If Romero decides to back the president, the early support could be important to Carter, whose prospects are considered poor in early New England races.

Carter's local campaign officials announced that he will spend about $800,000 here before the primary and will campaign here March 11. Kennedy has not said if or when he will come, but it is clear that he does not need Romero's help as much as Carter does. Tapestries of John F. Kennedy in the remote mountain homes of the Jivaros, the native farmers, testify to that.

The violence, a fact of life here for decades, crossed a vicious line Monday when two sailors were killed and 10 other Navy personnel were wounded in a terrorist fusillade into their shuttle bus. The wounded received purple hearts in a ceremony today as tightened security reminded everyone of the prospect of more trouble.

Before Monday, the various bombings and attacks had largely been scare tactics, timed to hurt nobody or to hit specific individuals named in the rhetoric of the elusive radical pro-independence groups.

Now Carter's people worry that the basically conservative Puerto Rican electorate will associate the violence with the release last September of four fiery Puerto Rican nationalists who had been jailed since the 1950s for terrorist attacks on U.S. politicians. Since their return here, the four have been urging Puerto Ricans to demand independence.

However, the nationalists were also out of the country when the attack occurred, in Mexico for an international rally boosting their cause. And nobody has tried to link them with the three pro-independence groups that claimed responsibility for Monday's attack.

Instead, Puerto Ricans seem resigned to the persistence of small, vaguely rooted groups which deal in violence and which are put in a class apart from the daily pull and haul of island politics.

"Everytime there have been violent acts, the people have reacted with a massive turnout to vote for parties that represent democratic ideals," said Franklin Delano Lopez, Carter's campaign chairman on the island.

Ruben B. Berrios, leader of the Puerto Rican Independence Party, underlined that history by being the first political figure to denounce the attack on the sailors. His party's international secretary, Roberto Aponte Toro, said today that the party has always favored the electoral route to victory. But Independentists have never topped 6 percent of the balloting at any time since 1952.

It is their undeniable frustration with the status quo, the Puerto Rican commonwealth relationship to the United States, that gives the independence forces weight and makes them the counter that Romero can use in his bargaining with Kennedy and Carter.

The island is poor, with 60 percent of the people on food stamps. Per capita income is about $2,300, half that of Mississippi. Romero has told people their future depends on statehood that would bring in billions in grants. From Carter he wants more help in 1980 and, from Kennedy, promises for later.

But Romero's hand is weakened with Kennedy, who has the firm backing of Romero's opposition, the Popular Democratic Party. The PDP created commonwealth status for the island in the 1930s, and now promotes a rejuvenated version. Kennedy has spoken kindly of commonwealth in the past, but, like Carter, is likely to adopt a neutral stance for the campaign, favoring whatever Puerto Ricans vote for in some future plebiscite.

Many of Romero's lieutenants are already leaning to Kennedy.His secretary of state, Pedro Vasquez, heads a pro-Kennedy committee, and his secretary of instruction and education, Carlos Chardon, admits to being a Kennedy loyalist.

"Kennedy will go for statehood if he sees that's where the votes are," Chardon said in an interview. "Carter's chances here depend on what he promises to deliver."

So Romero can offer less to Kennedy than he can to Carter, who may need Romero's charisma to boost him to victory. This is a tough one for Romero, since he will almost have to be with the winner of the national election if he wants to be reelected in 1980 and to lead his island to statehood thereafter.