key input sequence as action/reducer
This commit is contained in:
parent
adc6a5175c
commit
879b5afe66
9 changed files with 135 additions and 127 deletions
23
src/reducers/input.js
Normal file
23
src/reducers/input.js
Normal 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;
|
||||
}
|
||||
}
|
Reference in a new issue