The Shulchan Arukh dedicates a siman to kavanah in prayer: one should pray with deep concentration, imagining the Shekhinah before them, removing all distracting thoughts, and approaching prayer as if speaking directly to a king.
צריך שיהיה לו כוונה בתפלתו. ובו ה סעיפים: המתפלל צריך שיכוין בלבו פי' המלות שמוציא בשפתיו ויחשוב כאלו שכינה כנגדו ויסיר כל המחשבות הטורדות אותו עד שתשאר מחשבתו וכוונתו זכה בתפלתו ויחשוב כאלו היה מדבר לפני מלך בשר ודם היה מסדר דבריו ומכוין בהם יפה לבל יכשל ק"ו לפני ממ"ה הקב"ה שהוא חוקר כל המחשבות וכך היו עושים חסידים ואנשי מעשה שהיו מתבודדים ומכוונין בתפלתם עד שהיו מגיעים להתפשטות הגשמיות ולהתגברות כח השכלי עד שהיו מגיעים קרוב למעלת הנבואה ואם תבא לו מחשבה אחרת בתוך התפלה ישתוק עד שיתבטל המחשב' וצריך שיחשוב בדברי' המכניעים הלב ומכוונים אותו לאביו שבשמי' ולא יחשוב בדברי' שיש בהם קלות ראש: הגה ויחשוב קודם התפלה מרוממות האל יתעלה ובשפלו' האדם ויסיר כל תענוגי האדם מלבו [הר"י ריש פ' אין עומדין] ואסור לאדם לנשק בניו הקטנים בב"ה כדי לקבוע בלבו שאין אהבה כאהבת המקום ברוך הוא [בנימין זאב סימן קס"ג ואגודה פרק כיצד מברכין]: לא יתפלל במקום שיש דבר שמבטל כוונתו ולא בשעה המבטלת כוונתו [טור בשם ר"מ מרוטנבורג הגה"מ פ"ד מהלכו' תפלה] ועכשיו אין אנו נזהרין בכל זה מפני שאין אנו מכוונים כ"כ בתפלה:
One Needs to Have Concentration While Praying, containing 5 s'ifim: One who prays needs to concentrate on the meaning of the words which one brings forth from one's mouth. One should consider [it] as if the Divine Presence is opposite one, and remove all distracting thoughts from one, until one's thought and intention remain purely about one's prayer. And one should consider [it] as if one were speaking to before a king of flesh and blood, and one were organizing one's words beautifully and concentrating on them so as not to stumble, all the more [one should do so] before the King of kings of kings, the Holy One, who is Blessed, who examines all thoughts. And so did the pious ones and the men of action, who would seclude themselves and concentrate on their prayers until they would transcend [their] corporeality and strengthen [their] mental power, until nearly arriving at the level of prophecy. And if another thought comes to one in the midst of the prayer, one should be silent until the thought is eliminated. And one should think about things that humble the heart and concentrate it on one's Father in Heaven, and not think about things that contain levity ("light-headedness"). Gloss: Before prayer, one should think about the loftiness of God who is raised up and the lowliness of humanity, and remove all human pleasures from one's heart (Ri, beginning of chapter "Ein Om'din" [Berachot Chapter 5] ). And it is forbidden for a person to kiss one's small children in synagogue, in order to fix in one's heart that there is no love like the love of the Omnipresent Who is Blessed (Binyomin Ze'ev siman 163 and Agudah Chapter "Keitzad Mevarchin" [Berachot Chapter 6]). One should not pray in a place where there is something that negates one's concentration, and not at a time that negates one's concentration [Tur in the name of R. Meir of Rothenburg, Hagahot Maimoni on Chapter 4 from the Laws of Prayer]. And nowadays we are not careful with all of this since we are not able to concentrate so much during prayer.