diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-10 21:28:00 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2017-09-10 22:14:55 +0900 |
commit | 879b5afe66ee79424c3ffee3951ef1c0b8c86eaa (patch) | |
tree | 0306dfc26a4312f14084e295deefdf235abad34f /src/reducers | |
parent | adc6a5175c0d8b83e45b9e8d99109c1605ad29ac (diff) |
key input sequence as action/reducer
Diffstat (limited to 'src/reducers')
-rw-r--r-- | src/reducers/input.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/reducers/input.js b/src/reducers/input.js new file mode 100644 index 0000000..25ff1a3 --- /dev/null +++ b/src/reducers/input.js @@ -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; + } +} |