javascript - Simulating keypress events to navigate a website -
i'm working myo. it's armband connects computer via bluetooth. can detect movement of hand , can detect several gestures, such 'wave_left' , 'wave_right' , 'fingers_spread', 'fist' mainly. i've write javascript disabled persons can navigate website using myo. implement this, want map key press events myo gestures.
wave_left => tab
wave_right => shift + tab
fingers_spread => backspace
fist => enter
now here's code
<script src='http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.6.0/underscore-min.js'></script> <script src="https://cdn.rawgit.com/stolksdorf/myo.js/master/myo.js" ></script> <script src="https://cdn.rawgit.com/stolksdorf/myo.js/master/experimental/myo.experimental.js" ></script>
myo events handled here following
var myo = myo.create(0); myo.on('arm_recognized', function(){ console.log('arm found!', this.id); }); myo.on('arm_lost', function(){ console.log('arm lost', this.id); }); myo.on('wave_left', function(){ console.log('wave left!'); // tab key press event triggered }); myo.on('wave_right', function(){ console.log('wave right!'); // shift + tab key press event triggered }); myo.on('fingers_spread', function(){ console.log('spread!'); // backspace key press triggered }); myo.on('fist', function(){ console.log('fist'); // enter key press triggered }); myo.on('connected', function(){ }); myo.on('bluetooth_strength', function(bts){ console.log(width); }); myo.on('double_tap', function(){ console.log('double tap') ; }); myo.on('gyroscope', function(data){ });
i've searched internet. simulating tab key press, people suggested use $('some_element').next().focus()
, want native tab key press. this post says it's not possible because of security issue. post 2009, , html5 has progressed lot after then. possible trigger keypress event of special keys , native result? if possible, should do? in advance!
Comments
Post a Comment