Calculate cell-phone keypresses Your task is to calculate the total number of key-presses required to enter a given text on an old cellphone.

The keymaps are:

1:1
2:abcABC2
3:defDEF3
4:ghiGHI4
5:jklJKL5
6:mnoMNO6
7:pqrsPQRS7
8:tuvTUV8
9:wxyzWXYZ9
0:&lt;space&gt;&lt;newline&gt;0


To type exaMPle TExt 01 , you would press 33 99 2 6666 77777 555 33 0 8888 33333 99 8 0 &lt;a 1-sec pause here in real life but we'll ignore it&gt;000 1 for a total of 37 keypresses.

The * key brings up a map of special characters:

.,'?!
"-()@
/:_;+
&amp;%*=&lt;
&gt;£€$¥
¤[]{}
\~^¡¿
§#|`


with the first one (.) highlighted. You can move to highlight the required character using rectangular navigation keys and it takes another keypress to select.

So to insert $, you would press *↓↓↓↓→→→&lt;select&gt; i.e. a total of 9 key-presses.


Input will be from a file called source placed in the current directory/directory of your program.
EDIT: Per requests in comments, I'm adding STDIN as a valid input method.  Apologies for changing the spec after receiving answers. 
You must output Total key presses &lt;total_keypresses&gt; 
If the input file contains any character not in the given keymap, then your program must output Invalid character &lt;character&gt; in source and exit.


In short, the input and output of your program must resemble that of this(ungolfed) python script:

# This Python file uses the following encoding: utf-8
from __future__ import print_function
import sys

general_dict = { '1':1,
                 'a':1, 'b':2, 'c':3, 'A':4, 'B':5, 'C':6, '2':7,
                 'd':1, 'e':2, 'f':3, 'D':4, 'E':5, 'F':6, '3':7,
                 'g':1, 'h':2, 'i':3, 'G':4, 'H':5, 'I':6, '4':7,
                 'j':1, 'k':2, 'l':3, 'J':4, 'K':5, 'L':6, '5':7,
                 'm':1, 'n':2, 'o':3, 'M':4, 'N':5, 'O':6, '6':7,
                 'p':1, 'q':2, 'r':3, 's':4, 'P':5, 'Q':6, 'R':7, 'S':8, '7':9,
                 't':1, 'u':2, 'v':3, 'T':4, 'U':5, 'V':6, '8':7,
                 'w':1, 'x':2, 'y':3, 'z':4, 'W':5, 'X':6, 'Y':7, 'Z':8, '9':9,
                 ' ':1, '\n':2, '0':3
                }

special_chars = ['.',',',"'",'?','!','"','-','(',')','@','/',':','_',';','+','&amp;','%','*','=','&lt;','&gt;','£','€','$','¥','¤','[',']','{','}','\\','~','^','¡','¿','§','#','|','`']
for x in special_chars:
    general_dict[x]=(special_chars.index(x)/5) + (special_chars.index(x)%5) + 2

key_press_total = 0
with open('source') as f: # or # with sys.stdin as f:
    for line in f:
        for character in line:
            if character in general_dict:
                key_press_total+=general_dict[character]
            else:
                print('Invalid character',character,'in source')
                sys.exit(1)

print('Total key presses',key_press_total)


This is code-golf, shortest program in bytes wins.



Shameless disclaimer: I made this challenge to have translations of the above python script in different languages which will be used to score this challenge in the sandbox.
GolfScript, 219 characters
Basic approach using a lookup table:
&quot;Total key presses &quot;0@1/{&quot;1adgjmptw °behknqux\n.°cfilorvy0,\&quot;°ADGJMsTz'-/°BEHKNPUW?(:&amp;°CFILOQVX!)_%&gt;°23456R8Y@;*£¤°SZ+=€[~°79&lt;$]^§°¥{¡#°}¿|°`°&quot;.2$?)\1$&lt;&quot;°&quot;/,{&quot;Invalid character  in source&quot;18/*puts'&quot;#{''exit}&quot;'+~}if\;+}/

Try here.