hmApp.registerKeyEvent(function (key, action) {
console.log('receive key code:' + code + ' action:' + action)
let msg = ''
let ret = false
switch (key) {
case hmApp.key.BACK:
msg = 'back.'
break
case hmApp.key.SELECT:
msg = 'select.'
break
case hmApp.key.HOME:
msg = 'home.'
ret = true
break
case hmApp.key.UP:
msg = 'up.'
break
case hmApp.key.DOWN:
msg = 'down.'
break
case hmApp.key.SHORTCUT:
msg = 'shortcut.'
break
default:
msg = 'none.'
break
}
switch (action) {
case hmApp.action.CLICK:
msg = msg + 'click'
break
case hmApp.action.LONG_PRESS:
msg = msg + 'longPress'
break
case hmApp.action.DOUBLE_CLICK:
msg = msg + 'doubleClick'
break
case hmApp.action.RELEASE:
msg = msg + 'release'
break
case hmApp.action.PRESS:
msg = msg + 'press'
break
default:
msg = msg + 'none'
break
}
console.log('receive key:' + msg)
return ret
})