×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Dec 2004
    Location
    Czech Republic
    Posts
    50

    Keys? is it already supported?

    Hi,

    I'd like to hook the numeric keys. is it possible? I know about arrow keys constants (EKeyRightArrow etc.), "c" key (EKeyBackSpace") and that's all (only the right softkey hooked by appuifw.app.exit_key_handler). I've tried some constants from module key_codes but nearly nothing worked. So I ask again, is it possible to hook numeric keys(and others, like the green one and red one)? Thanks

  2. #2
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    My answer is a little script !

    Hello ,

    Code:
    from appuifw import *
    from e32 import *
    from key_codes import *
    import os
    import sys
    
    # Please add these lines below in key_codes.py in the lib folder (\system\libs)
    # EKeyA = 0x41 don' work :-(
    # EKeya = 0x61 don't work :-(
    # EKey1 = 0x31 
    # EKey2 = 0x32
    # EKey3 = 0x33
    # EKey4 = 0x34
    # EKey5 = 0x35
    # EKey6 = 0x36
    #EKey7 = 0x37
    # EKey8 = 0x38
    # EKey9 = 0x39
    #EKey0 = 0x30
    # EKeyStar = 0x2a
    # EKeyDiese = 0x23
    # EKeyEnter = 0x000d
    
    
    class my_app:
       def __init__(self):
           self.script_lock = Ao_lock()
           self.app_name= u'testkeys'
           self.app_ver= u'1'
           self.run_by = u''
           self.run_by_mode = u''
    
       def run(self):
           old_title = app.title
           app.title = self.app_name+self.app_ver
           app.body = Text()
           app.menu = [(u'Action ...',self.action),(u'About ...',self.about),(u'Quit', self.quit)]
           self.get_run_by()
           self.set_bind()
           app.exit_key_handler = self.fquit
           self.script_lock.wait()
           app.title = old_title
           app.body = None
    
       def quit(self):
           app.exit_key_handler = None
           self.script_lock.signal()
    
       def fquit(self):
           app.title = u'right soft key'
    
       def about(self):
           note(self.app_name+u'\n'+self.app_ver+u'\n'+u'(c) GPL license 2005\n'+self.run_by_mode+u'\nCreated by cyke64', 'info')
    
       def action(self):
           pass
       
       def key1(self):
           app.title = u'1'
       def key2(self):
           app.title = u'2'
       def key3(self):
           app.title = u'3'
       def key4(self):
           app.title = u'4'
       def key5(self):
           app.title = u'5'
       def key6(self):
           app.title = u'6'
       def key7(self):
           app.title = u'7'
       def key8(self):
           app.title = u'8'
       def key9(self):
           app.title = u'9'
       def key0(self):
           app.title = u'0'
       def keystar(self):
           app.title = u'times'
       def keydiese(self):
           app.title = u'diese'
       def keypen(self):
           app.title = u'pen'
       def keycancel(self):
           app.title = u'cancel'
       def keyyes(self):
           app.title = u'yes'
       def keyno(self):
           app.title = u'no'
       def keyjoy(self):
           app.title = u'joy'
       def keyleft(self):
           app.title = u'left'
       def keyright(self):
           app.title = u'right'
       def keyup(self):
           app.title = u'up'
       def keydown(self):
           app.title = u'down'
       def keymenu(self):
           app.title = u'menu'
       def keyenter(self):
           app.title = u'enter'
               
    
    
    
       def set_bind(self):
           app.body.bind(EKey1,self.key1)  # NEW !
           app.body.bind(EKey2,self.key2)  # NEW !
           app.body.bind(EKey3,self.key3)  # NEW !
           app.body.bind(EKey4,self.key4)  # NEW !
           app.body.bind(EKey5,self.key5)  # NEW !
           app.body.bind(EKey6,self.key6)  # NEW !
           app.body.bind(EKey7,self.key7)  # NEW !
           app.body.bind(EKey8,self.key8)  # NEW !
           app.body.bind(EKey9,self.key9)  # NEW !
           app.body.bind(EKey0,self.key0)  # NEW !
           app.body.bind(EKeyStar,self.keystar) # * key NEW !
           app.body.bind(EKeyDiese,self.keydiese) # NEW !
           app.body.bind(EKeyBackspace,self.keycancel) 
           app.body.bind(EKeyYes,self.keyyes) # it's the green key code !
           app.body.bind(EKeyNo,self.keyno) #it's the red key code but don't work !
           app.body.bind(EKeyMenu,self.keymenu) # don't work :-(
           app.body.bind(EKeyLeftArrow,self.keyleft)
           app.body.bind(EKeyRightArrow,self.keyright)
           app.body.bind(EKeyUpArrow,self.keyup)
           app.body.bind(EKeyDownArrow,self.keydown)
           app.body.bind(EKeyDevice3,self.keyjoy)
           app.body.bind(EKeyLeftShift,self.keypen)
           app.body.bind(EKeyEnter,self.keyenter) # press 0 three times !
    
       def set_exit_if_standalone(self):
           if self.run_by_mode == u'Python Installer':
              app.set_exit()
       
       def get_run_by(self):
           self.run_by = app.full_name()
           if self.run_by[-10:] == u'Python.app':
            self.run_by_mode = u'Python Interpreter'
           elif self.run_by[-10:] == u'appmgr.app':
            self.run_by_mode = u'Python Installer'
           else: 
            self.run_by_mode = u'Unknown ...'
    
    if __name__ == '__main__':
        my_app().run()

    Enjoy !

  3. #3
    Regular Contributor
    Join Date
    Dec 2004
    Location
    Czech Republic
    Posts
    50
    hey,

    you are great

    thanks.

  4. #4
    Registered User
    Join Date
    Apr 2005
    Location
    Frenstat pod Radhostem, Czech Republic
    Posts
    9

    Re: My answer is a little script !

    Wonderful and very useful. Thanks a lot.

    BTW: Is there a lot such a secrets that are not highligted in documentation? ;-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •