+#include "keycode.h"
+#include <list>
+
+class KeyList : protected std::list<KeyPress>
+{
+ typedef std::list<KeyPress> super;
+ typedef super::iterator iterator;
+ typedef super::const_iterator const_iterator;
+
+ virtual const_iterator find(const KeyPress &key) const
+ {
+ const_iterator f(begin());
+ const_iterator e(end());
+ while (f!=e) {
+ if (*f == key)
+ return f;
+ ++f;
+ }
+ return e;
+ }
+
+ virtual iterator find(const KeyPress &key)
+ {
+ iterator f(begin());
+ iterator e(end());
+ while (f!=e) {
+ if (*f == key)
+ return f;
+ ++f;
+ }
+ return e;
+ }
+
+public:
+ void clear() { super::clear(); }
+
+ void set(const KeyPress &key)
+ {
+ if (find(key) == end())
+ push_back(key);
+ }
+
+ void unset(const KeyPress &key)
+ {
+ iterator p(find(key));
+ if (p != end())
+ erase(p);
+ }
+
+ void toggle(const KeyPress &key)
+ {
+ iterator p(this->find(key));
+ if (p != end())
+ erase(p);
+ else
+ push_back(key);
+ }
+
+ bool operator[](const KeyPress &key) const
+ {
+ return find(key) != end();
+ }
+};