Arduino + Python to read input and output keypress

Afternoon.

I've been working on some arduino/python code to read a rotary encoder and a few buttons, when a button is pressed send a message to a python script and in turn output a keystroke to whichever program has the focus. this is where I am so far...

Arduino19 Code:

#include <RotaryEncoder.h>
#include <EEPROM.h>
#include <Button.h>

//PIN Defines
#define PIN_ENC_A 11
#define PIN_ENC_B 12
#define PIN_ENC_BTN 16
#define PIN_BTN_1 3
#define PIN_BTN_2 4
#define PIN_BTN_3 5
#define PIN_BTN_4 6
#define PIN_BTN_5 7
#define PIN_BTN_6 8
#define PIN_BTN_7 9
#define PIN_BTN_8 13
#define PIN_BTN_9 14
#define PIN_HBT 13

#define ADDR_BTN_1 10
#define ADDR_BTN_2 20
#define ADDR_BTN_3 30
#define ADDR_BTN_4 40
#define ADDR_BTN_5 50
#define ADDR_BTN_6 60
#define ADDR_BTN_7 70
#define ADDR_BTN_8 80
#define ADDR_BTN_9 90
#define ADDR_ENC_CW 100
#define ADDR_ENC_CCW 120
//Constructors
RotaryEncoder enc(PIN_ENC_A,PIN_ENC_B,PIN_ENC_BTN);
Button btn_1 = Button(PIN_BTN_1,PULLUP);
Button btn_2 = Button(PIN_BTN_2,PULLUP);
Button btn_3 = Button(PIN_BTN_3,PULLUP);
Button btn_4 = Button(PIN_BTN_4,PULLUP);
Button btn_5 = Button(PIN_BTN_5,PULLUP);
Button btn_6 = Button(PIN_BTN_6,PULLUP);
Button btn_7 = Button(PIN_BTN_7,PULLUP);
Button btn_8 = Button(PIN_BTN_8,PULLUP);
Button btn_9 = Button(PIN_BTN_9,PULLUP);

//Global Var
int encPos = 0;
int encNewPos = 0;

void setup()
{
//Set Buttons to Inputs
pinMode(PIN_ENC_A, INPUT);
pinMode(PIN_ENC_B, INPUT);
pinMode(PIN_ENC_BTN, INPUT);
pinMode(PIN_BTN_1, INPUT);
pinMode(PIN_BTN_2, INPUT);
pinMode(PIN_BTN_3, INPUT);
pinMode(PIN_BTN_4, INPUT);
pinMode(PIN_BTN_5, INPUT);
pinMode(PIN_BTN_6, INPUT);
pinMode(PIN_BTN_7, INPUT);
pinMode(PIN_BTN_8, INPUT);
pinMode(PIN_BTN_9, INPUT);
pinMode(PIN_HBT, OUTPUT);
//Enable in-chip PullUp resistors
digitalWrite(PIN_BTN_1 , INPUT);
digitalWrite(PIN_BTN_2 , INPUT);
digitalWrite(PIN_BTN_3 , INPUT);
digitalWrite(PIN_BTN_4 , INPUT);
digitalWrite(PIN_BTN_5 , INPUT);
digitalWrite(PIN_BTN_6 , INPUT);
digitalWrite(PIN_BTN_7 , INPUT);
digitalWrite(PIN_BTN_8 , INPUT);
digitalWrite(PIN_BTN_9 , INPUT);

Serial.begin(9600);
//Serial.println("START");
}

void loop()
{
//read Encoder
encNewPos = enc.position();
if (encNewPos != encPos)
{
if (encNewPos < encPos)
{
SendKeyStroke(ADDR_ENC_CCW);

}

if (encNewPos > encPos)
{
SendKeyStroke(ADDR_ENC_CW);
}

encPos = encNewPos;
//read Keypad

}
}

void SendKeyStroke(int c)
{
Serial.print(EEPROM.read(c));
}

and the python3.1.2 code:

import serial

port = "COM2"
ser = serial.Serial(port,9600)
value = 0

while 1:
value = ser.read();
print(type(value))
print(value)
strValue = value.decode("utf-8")
if strValue == "m":
print("CCW")
elif strValue == "k":
print("CW")
#elif strValue != "m" or strValue != "k":
#print("Value not recognised")
else:
continue

This is my first look at python, and in one evening this is what i've come up with. Now the problems...

I've only implemented the rotary encoder so far, and it seems to work ok but i was wondering if there was a better way to handle the reading of the serial input? it seems a bit long winded and will end up with a whole lot of 'if.. elif' code when i get round to implementing the next 9 buttons.

Also, what would be the best way to code in an escape sequence to handle closing the serial port if the script is terminated?

Not looking for the answers, just a point in the right direction! Many thanks in advance!