Page tree
Skip to end of metadata
Go to start of metadata

Android key codes are available to use with Smartface. You don’t need to change any key code to work with Smartface. Just use same key code which is given by Google.

 

Android Key Codes

Back Button: 4

Menu Button: 82

Select (Middle) Button: 23

Usage of Key Codes in Smartface

Select the ‘OnKeyPress’ event and write down which key you want to use with function. In this example, pressing on Android back button key (Physical or On Screen key) get you out of that application.

Pages.pgMain = new SMF.UI.Page({
        name : "pgMain",
        onKeyPress : pgMain_onKeyPress,
        onShow : pgMain_onShow,
        backgroundImage : "images://background.png"
    });

function pgMain_onKeyPress(e) {
    if (e.keyCode === 4) {
        Application.exit();
    }
}

If you want to go previous page with using this key:

 

Pages.pgMain = new SMF.UI.Page({
        name : "pgMain",
        onKeyPress : pgMain_onKeyPress,
        onShow : pgMain_onShow,
        backgroundImage : "images://background.png"
    });

function pgMain_onKeyPress(e) {
    if (e.keyCode === 4) {
        Pages.back();
    }
}