Android数字键盘按键未触发

时间:2017-02-07 10:41:52

标签: android html angularjs android-softkeyboard

我创建了一个简单的AngularJs指令,它将绑定添加到“keypress”事件:

namespace X
{
    public class App : Application
    {
        INotificationService service;           
    }


    void CheckNotifications ()
    {
        service = DependencyService.Get<INotificationService> ();
        service.Notify (message);
        System.Threading.Thread.Sleep (1000 * 60);          
     }

     protected override void OnStart ()
     {          
            var threadStart = new System.Threading.ThreadStart (CheckNotifications);
            var thread = new System.Threading.Thread (threadStart);
            thread.IsBackground = true;
            thread.Start ();
     }

}

只是为了测试,有“绑定”和“打开”挂钩。这适用于iOS设备。但是在Android中,如果你按逗号,输入或不是一个数字,事件将不会触发。

working JSFiddle, open it on Android device

更新

我补充说:

app.directive('filterInput', function() {
    return {
        restrict: 'A',        
        scope: {},
        link: function(scope, elem, attr) {

            elem.bind('keypress', function(e) {
                alert(e.code || e.which);
            })

            elem.on('keypress', function(e) {
                alert(e.code || e.which);
            })

        }
    }
})

现在事件正在为所有键触发(事件代码未定义),但输入(键码13)除外。不幸的是,我需要截取那个密钥。

0 个答案:

没有答案