The modal words express the attitude of the speaker to the reality, possibility, or probability, of the action he speaks about. According to their meaning modal words fall under the following main groups:
#1. words expressing certainty
certainly, surely, assuredly, of course, no doubt, apparently, undoubtedly, etc.;
#2. words expressing supposition
perhaps, maybe, possibly, probably, etc.;
#3. words showing whether the speaker considers the action he speaks about desirable or undesirable
happily — unhappily; luckily — unluckily; fortunately – unfortunately;
Function
In the sentence, modal words are used as parentheses. Sometimes they are used as sentence-words.[1]
Certainly you’ll admit we could finish all this in a month. (Wilson)
“Will you allow me to detain you one moment,” said he. “Certainly,” replied the unwelcome visitor. (Dickens)
Most modal words have developed from adverbs, so very often there exists a formal identity between modal words and adverbs. For instance, such modal words as certainly, surely, happily are homonymous with the adverbs certainly, surely, happily.
Such modal words as possibly, probably, indeed, also derived from adverbs, have no corresponding homonymous adverbs because the latter ceased to be used in Modern English.
Though formally identical to adverbs, modal words differ from them in meaning and syntactical function.
If he were not married as happily as he was, might not something come of it? (Dreiser) (ADVERB)
…she hauled me to the washstand, inflicted a merciless, but happily brief scrub on my face and hands with soap water, and a coarse towel… (Ch. Bronte) (MODAL WORD)
Lamlein rose. “We have fulfilled our obligations,” he said pompously, and yet not quite certainly. (Heym) (ADVERB)
Soames smiled. Certainly, uncle Jolyon had a way with him. (Galsworthy) (MODAL WORD)
Slowly, surely, with the secret inner process that works the destruction of an old tree, the poison of the wounds to his happiness, his will, his pride, had corroded the comely edifice of his philosophy. (Galsworthy) (ADVERB)
Over the ridge she would find him. Surely she would find him over the ridge. (Wells) (MODAL WORD)
[1] Modal words used as sentence-words are similar to the words yes and no expressing affirmation and negation, which are also sentence-words.