Typing an underscore is the same for a Windows or a Mac computer. On most standard keyboard layouts, the underscore shares a key with the hyphen character. Type it by pressing the Shift and Hyphen keys. On standard U.S. keyboards, the hyphen key is located on the top row, to the right of the zero key. Onscreen keyboards for mobile devices vary; mobile devices have dozens of keyboards to choose from as downloadable apps. Most, however, follow a standard layout.
The standard to underline text used to be Ctrl-U. However, this shortcut is growing obsolete. Instead, highlight the text to be underlined and then right-click on the text, which often produces a menu with formatting options, including Underline. Alternatively, check the application's menus for a Format menu, which usually contains an underline option.
On Mobile Devices
On mobile on-screen keyboards, the underscore key is not immediately visible, so it takes multiple taps every time you want to type an underscore.
iOS (iPhone, iPad, iPod Touch)
Tap the 123 button. On the iPad, the button reads .?123 instead.
Tap the #+= button.
Tap the Underscore button. From here, you can tap either 123 to return to the numbers keys or ABC to return to the alphabetic keyboard.
Tap the ?123 button.
Tap the Underscore button. When finished, tap either ~[< to open the keyboard with additional characters or ABC to return to the alphabetic keys.