Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Method 1:
If I see well, you have 16-bits stack segment. In pmode you must set cs,ds,es,fs,gs,ss in 32-bits segments( If you use 32 bits protected mode)
Method 2:
Check that you have flushed keyboard buffer (this may help only with the keyboard problem)
Method 3:
Tips: Typicaly segments are sets that:
cs = 32bit code segment
ds = es = fs = gs = ss = 32 bit data segment
But I don't belive that its segments problem. Meabe your's outb functions not works correctly?