key input sequence as action/reducer

This commit is contained in:
Shin'ya Ueoka 2017-09-10 21:28:00 +09:00
parent adc6a5175c
commit 879b5afe66
9 changed files with 135 additions and 127 deletions

23
src/reducers/input.js Normal file
View file

@ -0,0 +1,23 @@
import actions from '../actions';
const defaultState = {
keys: [],
};
export default function reducer(state = defaultState, action = {}) {
switch (action.type) {
case actions.INPUT_KEY_PRESS:
return Object.assign({}, state, {
keys: state.keys.concat([{
code: action.code,
ctrl: action.ctrl
}])
});
case actions.INPUT_CLEAR_KEYS:
return Object.assign({}, state, {
keys: [],
});
default:
return state;
}
}